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 2, 2017
1 parent 21f4fc4 commit 69cdbe7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plugins/labhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,27 @@ 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, self.room.name, re.IGNORECASE)

if roommatch is None:
return None

return roommatch.group(1), roommatch.group(2), m.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
5 changes: 5 additions & 0 deletions tests/labhub_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ 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()
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 69cdbe7

Please sign in to comment.