Skip to content

Commit

Permalink
Make sure Homu hidden approval command parses
Browse files Browse the repository at this point in the history
Homu leaves self-approvals in comments, like

    <!-- @bors r=someone abcdef -->

and we need to make sure those still parse correctly.
  • Loading branch information
bryanburgers committed Jun 12, 2019
1 parent 0194c3a commit dc435f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion homu/parse_issue_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,14 @@ def parse_issue_comment(username, body, sha, botname, hooks=[]):
E.g. `['hook1', 'hook2', 'hook3']`
"""

words = list(chain.from_iterable(re.findall(r'\S+', x) for x in body.splitlines() if '@' + botname in x)) # noqa
botname_regex = re.compile(r'^.*(?=@' + botname + ')')

# All of the 'words' after and including the botname
words = list(chain.from_iterable(
re.findall(r'\S+', re.sub(botname_regex, '', x))
for x
in body.splitlines()
if '@' + botname in x)) # noqa

commands = []

Expand Down
16 changes: 16 additions & 0 deletions homu/tests/test_parse_issue_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ def test_r_equals():
assert command.actor == 'jill'


def test_hidden_r_equals():
author = "bors"
body = """
:pushpin: Commit {0} has been approved by `jack`
<!-- @bors r=jack {0} -->
""".format(commit)

commands = parse_issue_comment(author, body, commit, "bors")

assert len(commands) == 1
command = commands[0]
assert command.action == 'approve'
assert command.actor == 'jack'
assert command.commit == commit


def test_r_me():
"""
Ignore r=me
Expand Down

0 comments on commit dc435f6

Please sign in to comment.