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

Commit af3efc5

Browse files
Merge pull request #281 from jyn514/master
Don't ping file reviewers if they are the PR author
2 parents 0df3961 + 7f29f7c commit af3efc5

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

highfive/newpr.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,14 @@ def choose_reviewer(self, repo, owner, diff, exclude):
311311
# no eligible reviewer found
312312
return None
313313

314-
def get_to_mention(self, diff):
314+
def get_to_mention(self, diff, author):
315315
"""
316316
Get the list of people to mention.
317317
"""
318318
dirs = self.repo_config.get('dirs', {})
319319
mentions = self.repo_config.get('mentions', {})
320320

321-
to_mention = []
321+
to_mention = set()
322322
# If there's directories with specially assigned groups/users
323323
# inspect the diff to find the directory with the most additions
324324
if dirs:
@@ -340,15 +340,16 @@ def get_to_mention(self, diff):
340340
cur_dir = None
341341
if len(full_dir) > 0:
342342
for entry in mentions:
343-
if full_dir.startswith(entry) and entry not in to_mention:
344-
to_mention.append(entry)
345-
elif (entry.endswith('.rs') and full_dir.endswith(entry)
346-
and entry not in to_mention):
347-
to_mention.append(entry)
343+
if full_dir.startswith(entry):
344+
to_mention.add(entry)
345+
elif entry.endswith('.rs') and full_dir.endswith(entry):
346+
to_mention.add(entry)
348347

349348
mention_list = []
350349
for mention in to_mention:
351-
mention_list.append(mentions[mention])
350+
entry = mentions[mention]
351+
if entry["reviewers"] != author:
352+
mention_list.append(entry)
352353
return mention_list
353354

354355
def add_labels(self, owner, repo, issue):
@@ -379,7 +380,7 @@ def new_pr(self):
379380
reviewer = self.choose_reviewer(
380381
repo, owner, diff, author
381382
)
382-
to_mention = self.get_to_mention(diff)
383+
to_mention = self.get_to_mention(diff, author)
383384

384385
self.set_assignee(
385386
reviewer, owner, repo, issue, self.integration_user,

highfive/tests/test_newpr.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ def test_msg_reviewer_repeat_contributor(self):
817817

818818
self.assert_set_assignee_branch_calls('foundReviewer', ['to'])
819819
self.mocks['choose_reviewer'].assert_not_called()
820-
self.mocks['get_to_mention'].assert_called_once_with('diff')
820+
self.mocks['get_to_mention'].assert_called_once_with('diff', 'prAuthor')
821821
self.mocks['welcome_msg'].assert_not_called()
822822
self.mocks['review_msg'].assert_not_called()
823823
self.mocks['post_comment'].assert_not_called()
@@ -1037,13 +1037,13 @@ def make_fakes(cls):
10371037
'global_': fakes.get_global_configs(),
10381038
}
10391039

1040-
def get_to_mention(self, diff, global_=None):
1041-
return self.get_to_mention_inner(diff, global_)
1040+
def get_to_mention(self, diff, author, global_=None):
1041+
return self.get_to_mention_inner(diff, author, global_)
10421042

10431043
@mock.patch('highfive.newpr.HighfiveHandler._load_json_file')
1044-
def get_to_mention_inner(self, diff, global_, mock_load_json):
1044+
def get_to_mention_inner(self, diff, author, global_, mock_load_json):
10451045
mock_load_json.return_value = deepcopy(global_ or {"groups": {}})
1046-
return self.handler.get_to_mention(diff)
1046+
return self.handler.get_to_mention(diff, author)
10471047

10481048
def choose_reviewer(
10491049
self, repo, owner, diff, exclude, global_=None

0 commit comments

Comments
 (0)