diff --git a/plugins/labhub.py b/plugins/labhub.py index 7419eea6..61949b52 100644 --- a/plugins/labhub.py +++ b/plugins/labhub.py @@ -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: diff --git a/tests/labhub_test.py b/tests/labhub_test.py index df467f3a..d7c71521 100644 --- a/tests/labhub_test.py +++ b/tests/labhub_test.py @@ -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()