@@ -27,7 +27,12 @@ def good_labels(subject_tags, labels):
2727 label_tags = set ()
2828
2929 for label in labels :
30- label_tags .update (LABEL_TO_TAG [label ])
30+ tags = LABEL_TO_TAG .get (label )
31+
32+ if tags is None :
33+ return False
34+
35+ label_tags .update (tags )
3136
3237 if subject_tags .issubset (label_tags ):
3338 return True
@@ -93,7 +98,7 @@ def verify_subject_tags(invalid_tags, required_tags):
9398
9499
95100def verify_other_lengths (other_lines ):
96- # aggregate line_exceed results together
101+ # aggregate line_exceed results
97102 other_violation = reduce (lambda x , y : x | y ,
98103 map (line_exceeds , other_lines ))
99104
@@ -110,7 +115,7 @@ def verify_metadata(valid_tags, last_lines):
110115 warning ('Required metadata tags' )
111116 exit (6 )
112117
113- # collect all metadata labels
118+ # collect metadata labels
114119 labels = map (lambda l : l .split (':' )[0 ], last_lines )
115120
116121 if good_labels (subject_tags , labels ) is False :
@@ -125,10 +130,14 @@ def main():
125130 with io .open (commit_flname ) as fl :
126131 commit_fl = fl .read ().splitlines ()
127132
133+ # ignore comments
134+ commit_fl = filter (
135+ lambda l : not l .startswith ('#' ), commit_fl )
136+
128137 subject_line = commit_fl .pop (0 )
129138 i_tags , r_tags , s_tags = analyze_tags (subject_line )
130139
131- # filter lines with metadata labels
140+ # select metadata lines
132141 last_lines = filter (
133142 lambda l : len (l .split (':' )) == 2 , commit_fl )
134143
0 commit comments