Skip to content

Commit

Permalink
labhub/assign: Support super-short issue ref
Browse files Browse the repository at this point in the history
... of the form `#1234`.

Closes #167
  • Loading branch information
Makman2 committed Oct 15, 2017
1 parent 1595a3d commit b67c4d5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
22 changes: 21 additions & 1 deletion plugins/labhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,29 @@ def process_short_ref(issue_reference):

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

# Super short issue reference (e.g. `#1234`)
def process_super_short_ref(issue_reference):
issue_rgx = r'#(\d+)'
issue_reference_match = re.fullmatch(issue_rgx, issue_reference)

if issue_reference_match is None:
return None

roomname_rgx = r'(.+?)/(.+)'
roomname_match = re.fullmatch(
roomname_rgx, msg.frm.room.uri, re.IGNORECASE)

if roomname_match is None:
return None

return (roomname_match.group(1),
roomname_match.group(2),
issue_reference_match.group(1))

issue_processors = [
process_full_url,
process_short_ref
process_short_ref,
process_super_short_ref
]

for issue_processor in issue_processors:
Expand Down
6 changes: 6 additions & 0 deletions tests/labhub_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ def test_assign_cmd(self):
testbot.assertCommand('!assign coala/a#23',
"You've been assigned to the issue")

# test super-short issue reference
mock_issue.assignees = tuple()
self.mock_team.is_member.return_value = False
testbot.assertCommand('!assign #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 b67c4d5

Please sign in to comment.