Skip to content

Commit cb09d1f

Browse files
committed
labhub/assign: Support super-short issue ref
... of the form `#1234`. Closes #167
1 parent 1595a3d commit cb09d1f

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎plugins/labhub.py‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,27 @@ def process_short_ref(issue_reference):
266266

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

269+
# Super short issue reference (e.g. `#1234`)
270+
def process_super_short_ref(issue_reference):
271+
issue_rgx = r'#(\d+)'
272+
issue_reference_match = re.fullmatch(issue_rgx, issue_reference)
273+
274+
if issue_reference_match is None:
275+
return None
276+
277+
roomname_rgx = r'(.+?)/(.+)'
278+
roomname_match = re.fullmatch(
279+
roomname_rgx, msg.frm.room.idd, re.IGNORECASE)
280+
281+
if roommatch is None:
282+
return None
283+
284+
return roommatch.group(1), roommatch.group(2), m.group(1)
285+
269286
issue_processors = [
270287
process_full_url,
271-
process_short_ref
288+
process_short_ref,
289+
process_super_short_ref
272290
]
273291

274292
for issue_processor in issue_processors:

‎tests/labhub_test.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ def test_assign_cmd(self):
158158
testbot.assertCommand('!assign coala/a#23',
159159
"You've been assigned to the issue")
160160

161+
# test super-short issue reference
162+
mock_issue.assignees = tuple()
163+
self.mock_team.is_member.return_value = False
164+
testbot.assertCommand('!assign #23',
165+
"You've been assigned to the issue")
166+
161167
cmd = '!assign https://github.com/{}/{}/issues/{}'
162168
# no assignee, not newcomer
163169
mock_issue.assignees = tuple()

0 commit comments

Comments
 (0)