Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Commit f2ef639

Browse files
Merge pull request #350 from LeSeulArtichaut/assign-team
Allow r? assignment of team without ping
2 parents ad02a63 + 6121a41 commit f2ef639

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

highfive/newpr.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
review_with_reviewer = 'r? @%s\n\n(rust-highfive has picked a reviewer for you, use r? to override)'
3434
review_without_reviewer = '@%s: no appropriate reviewer found, use r? to override'
3535

36-
reviewer_re = re.compile("\\b[rR]\?[:\- ]*@(?:([a-zA-Z0-9\-]+)/)?([a-zA-Z0-9\-]+)")
36+
reviewer_re = re.compile("\\b[rR]\?[:\- ]*@([a-zA-Z0-9\-]+)")
37+
reviewer_group_re = re.compile("\\b[rR]\?[:\- ]*@?(?:([a-zA-Z0-9\-]+)/)([a-zA-Z0-9\-]+)")
3738
submodule_re = re.compile(".*\+Subproject\scommit\s.*", re.DOTALL | re.MULTILINE)
3839
target_re = re.compile("^[+-]{3} [ab]/compiler/rustc_target/src/spec/", re.MULTILINE)
3940

@@ -248,22 +249,17 @@ def find_reviewer(self, msg, exclude):
248249
None.
249250
"""
250251
if msg is not None:
252+
match = reviewer_group_re.search(msg)
253+
if match:
254+
groups = self.get_groups()
255+
potential = groups.get(match.group(2)) or groups.get("%s/%s" % (match.group(1), match.group(2))) or []
256+
potential.extend(groups["all"])
257+
return self.pick_reviewer(groups, potential, exclude)
258+
251259
match = reviewer_re.search(msg)
252260
if match:
253-
if match.group(1):
254-
# assign someone from the specified team
255-
groups = self.get_groups()
256-
potential = groups.get(match.group(2))
257-
if potential is None:
258-
potential = groups.get("%s/%s" % (match.group(1), match.group(2)))
259-
if potential is None:
260-
potential = groups["all"]
261-
else:
262-
potential.extend(groups["all"])
263-
264-
return self.pick_reviewer(groups, potential, exclude)
265-
else:
266-
return match.group(2)
261+
return match.group(1)
262+
267263

268264
def choose_reviewer(self, repo, owner, diff, exclude):
269265
"""Choose a reviewer for the PR."""

highfive/tests/test_newpr.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,12 +1268,15 @@ def test_with_team_ping(self):
12681268

12691269
found_cases = (
12701270
("r? @foo/a", "pnkfelix"),
1271+
("r? foo/a", "pnkfelix"),
12711272
("r? @b/c", "nrc"),
1273+
("r? b/c", "nrc"),
12721274
)
12731275

12741276
not_found_cases = (
12751277
"r? @/a",
12761278
"r? @a/b",
1279+
"r? pnkfelix",
12771280
)
12781281

12791282
for (msg, reviewer) in found_cases:

0 commit comments

Comments
 (0)