Skip to content

Commit dc435f6

Browse files
committed
Make sure Homu hidden approval command parses
Homu leaves self-approvals in comments, like <!-- @bors r=someone abcdef --> and we need to make sure those still parse correctly.
1 parent 0194c3a commit dc435f6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

homu/parse_issue_comment.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ def parse_issue_comment(username, body, sha, botname, hooks=[]):
151151
E.g. `['hook1', 'hook2', 'hook3']`
152152
"""
153153

154-
words = list(chain.from_iterable(re.findall(r'\S+', x) for x in body.splitlines() if '@' + botname in x)) # noqa
154+
botname_regex = re.compile(r'^.*(?=@' + botname + ')')
155+
156+
# All of the 'words' after and including the botname
157+
words = list(chain.from_iterable(
158+
re.findall(r'\S+', re.sub(botname_regex, '', x))
159+
for x
160+
in body.splitlines()
161+
if '@' + botname in x)) # noqa
155162

156163
commands = []
157164

homu/tests/test_parse_issue_comment.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ def test_r_equals():
5252
assert command.actor == 'jill'
5353

5454

55+
def test_hidden_r_equals():
56+
author = "bors"
57+
body = """
58+
:pushpin: Commit {0} has been approved by `jack`
59+
<!-- @bors r=jack {0} -->
60+
""".format(commit)
61+
62+
commands = parse_issue_comment(author, body, commit, "bors")
63+
64+
assert len(commands) == 1
65+
command = commands[0]
66+
assert command.action == 'approve'
67+
assert command.actor == 'jack'
68+
assert command.commit == commit
69+
70+
5571
def test_r_me():
5672
"""
5773
Ignore r=me

0 commit comments

Comments
 (0)