@@ -93,6 +93,7 @@ def verify_subject_tags(invalid_tags, required_tags):
9393
9494
9595def verify_other_lengths (other_lines ):
96+ # aggregate line_exceed results together
9697 other_violation = reduce (lambda x , y : x | y ,
9798 map (line_exceeds , other_lines ))
9899
@@ -109,6 +110,7 @@ def verify_metadata(valid_tags, last_lines):
109110 warning ('Required metadata tags' )
110111 exit (6 )
111112
113+ # collect all metadata labels
112114 labels = map (lambda l : l .split (':' )[0 ], last_lines )
113115
114116 if good_labels (subject_tags , labels ) is False :
@@ -122,21 +124,23 @@ def main():
122124
123125 with io .open (commit_flname ) as fl :
124126 commit_fl = fl .read ().splitlines ()
125- subject_line = commit_fl .pop (0 )
126- i_tags , r_tags , s_tags = analyze_tags (subject_line )
127127
128- last_lines = filter (
129- lambda l : len ( l . split ( ':' )) == 2 , commit_fl )
128+ subject_line = commit_fl . pop ( 0 )
129+ i_tags , r_tags , s_tags = analyze_tags ( subject_line )
130130
131- valid_tags = r_tags + s_tags
131+ # filter lines with metadata labels
132+ last_lines = filter (
133+ lambda l : len (l .split (':' )) == 2 , commit_fl )
132134
133- verify_subject_length (subject_line )
134- verify_subject_tags (i_tags , r_tags )
135+ valid_tags = r_tags + s_tags
135136
136- if len ( commit_fl ) > 1 :
137- verify_other_lengths ( commit_fl )
137+ verify_subject_length ( subject_line )
138+ verify_subject_tags ( i_tags , r_tags )
138139
139- verify_metadata (valid_tags , last_lines )
140+ if len (commit_fl ) > 1 :
141+ verify_other_lengths (commit_fl )
142+
143+ verify_metadata (valid_tags , last_lines )
140144
141145if __name__ == '__main__' :
142146 main ()
0 commit comments