Skip to content

Commit a92b80d

Browse files
author
Samuel Huang
committed
check-msg.py: ignore comments and check label
1 parent f9617ad commit a92b80d

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

check-msg.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

95100
def 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

sample-commit.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[BUGFIX] Fix Add Load button
2+
3+
One of the AJAX calls to the REST API is incorrect because the URL
4+
is malformed. I am changing it from _________ to _________, so
5+
the button onClick works.
6+
7+
Closes-Bug: #11

0 commit comments

Comments
 (0)