Skip to content

Commit

Permalink
labhub/assign: Support short issue references
Browse files Browse the repository at this point in the history
... of the form `#12`.
  • Loading branch information
Makman2 committed Oct 2, 2017
1 parent f565622 commit 21f4fc4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion plugins/labhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,19 @@ def process_full_url(issue_reference):

return m.group(2), m.group(3)[:-1], m.group(4)

# Short issue reference (e.g. `coala/corobo#12`)
def process_short_ref(issue_reference):
rgx = r'(.+?)/(.+?)#(\d+)'
m = re.fullmatch(rgx, issue_reference, re.IGNORECASE)

if m is None:
return None

return m.group(1), m.group(2), m.group(3)

issue_processors = [
process_full_url
process_full_url,
process_short_ref
]

for issue_processor in issue_processors:
Expand Down
5 changes: 5 additions & 0 deletions tests/labhub_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ def test_assign_cmd(self):
testbot.assertCommand(cmd,
'Invalid issue.')

# test short issue reference
mock_issue.assignees = tuple()
testbot.assertCommand('!assign coala/a#23',
"You've been assigned to the issue")

cmd = '!assign https://github.com/{}/{}/issues/{}'
# no assignee, not newcomer
mock_issue.assignees = tuple()
Expand Down

0 comments on commit 21f4fc4

Please sign in to comment.