Skip to content

Commit d06b990

Browse files
committed
feature #215 Removing suggest contributor feature (weaverryan)
This PR was squashed before being merged into the master branch. Discussion ---------- Removing suggest contributor feature Fixes #214 Commits ------- afe12c4 Removing suggest contributor feature
2 parents 35bec43 + afe12c4 commit d06b990

26 files changed

+12
-928
lines changed

.github/workflows/find-reviewer.yml

Lines changed: 0 additions & 99 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ Carson will look for old inactive issues and start a process with them.
8484
The process can be interrupted with anyone making a comment on the issue or the
8585
"Keep open" label is added.
8686

87-
### Suggest reviewers
88-
89-
Carson can look at the PR to figure out who will be a good candidate to review the
90-
changes. This can be triggered by someone can make a comment in a PR to say
91-
`@carsonbot find me a reviewer please` (or really anything with `@carsonbot` and
92-
`review` on the same line).
93-
94-
Carson will also try to find a reviewer if there is no activity on a new PR within
95-
the first 20 hours.
96-
9787
### Add a warning if pull request target unsupported branch
9888

9989
If a PR is opened towards a branch that is not maintained anymore, Carson will

config/packages/github_api.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,10 @@ services:
5050
Github\Api\Issue\Milestones:
5151
factory: ['@Github\Api\Issue', milestones]
5252

53-
Github\Api\Issue\Timeline:
54-
factory: ['@Github\Api\Issue', timeline]
55-
calls:
56-
- [configure]
57-
5853
Github\Api\PullRequest:
5954
factory: ['@Github\Client', api]
6055
arguments: [pullRequest]
6156

62-
Github\Api\PullRequest\Review:
63-
factory: ['@Github\Api\PullRequest', reviews]
64-
6557
Github\Api\Repo:
6658
factory: ['@Github\Client', api]
6759
arguments: [repo]

config/services.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ parameters:
77
- 'App\Subscriber\StatusChangeByReviewSubscriber'
88
- 'App\Subscriber\NeedsReviewNewPRSubscriber'
99
- 'App\Subscriber\BugLabelNewIssueSubscriber'
10-
- 'App\Subscriber\FindReviewerSubscriber'
1110
- 'App\Subscriber\AutoLabelFromContentSubscriber'
1211
- 'App\Subscriber\MilestoneNewPRSubscriber'
1312
- 'App\Subscriber\MilestoneMergedPRSubscriber'
@@ -49,7 +48,6 @@ parameters:
4948
- 'App\Subscriber\StatusChangeByReviewSubscriber'
5049
- 'App\Subscriber\NeedsReviewNewPRSubscriber'
5150
- 'App\Subscriber\BugLabelNewIssueSubscriber'
52-
- 'App\Subscriber\FindReviewerSubscriber'
5351
- 'App\Subscriber\AutoLabelFromContentSubscriber'
5452
- 'App\Subscriber\MilestoneNewPRSubscriber'
5553
- 'App\Subscriber\MilestoneMergedPRSubscriber'

src/Api/Issue/GithubIssueApi.php

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,23 @@
55
use App\Model\Repository;
66
use Github\Api\Issue;
77
use Github\Api\Issue\Comments;
8-
use Github\Api\Issue\Timeline;
9-
use Github\Api\PullRequest\Review;
108
use Github\Api\Search;
11-
use Github\Exception\RuntimeException;
129
use Github\ResultPager;
1310

1411
class GithubIssueApi implements IssueApi
1512
{
1613
private $resultPager;
1714
private $issueCommentApi;
18-
private $reviewApi;
1915
private $issueApi;
2016
private $searchApi;
21-
private $timelineApi;
2217
private $botUsername;
2318

24-
public function __construct(ResultPager $resultPager, Comments $issueCommentApi, Review $reviewApi, Issue $issueApi, Search $searchApi, Timeline $timelineApi, string $botUsername)
19+
public function __construct(ResultPager $resultPager, Comments $issueCommentApi, Issue $issueApi, Search $searchApi, string $botUsername)
2520
{
2621
$this->resultPager = $resultPager;
2722
$this->issueCommentApi = $issueCommentApi;
28-
$this->reviewApi = $reviewApi;
2923
$this->issueApi = $issueApi;
3024
$this->searchApi = $searchApi;
31-
$this->timelineApi = $timelineApi;
3225
$this->botUsername = $botUsername;
3326
}
3427

@@ -62,31 +55,6 @@ public function lastCommentWasMadeByBot(Repository $repository, $number): bool
6255
return $this->botUsername === ($lastComment['user']['login'] ?? null);
6356
}
6457

65-
/**
66-
* Has this PR or issue comments/reviews from others than the author?
67-
*/
68-
public function hasActivity(Repository $repository, $number): bool
69-
{
70-
$issue = $this->issueApi->show($repository->getVendor(), $repository->getName(), $number);
71-
$author = $issue['user']['login'] ?? null;
72-
73-
try {
74-
$reviewComments = $this->reviewApi->all($repository->getVendor(), $repository->getName(), $number, ['per_page' => 100]);
75-
} catch (RuntimeException $e) {
76-
// This was not a PR =)
77-
$reviewComments = [];
78-
}
79-
80-
$all = array_merge($reviewComments, $this->issueCommentApi->all($repository->getVendor(), $repository->getName(), $number, ['per_page' => 100]));
81-
foreach ($all as $comment) {
82-
if (!in_array($comment['user']['login'], [$author, $this->botUsername])) {
83-
return true;
84-
}
85-
}
86-
87-
return false;
88-
}
89-
9058
public function show(Repository $repository, $issueNumber): array
9159
{
9260
return $this->issueApi->show($repository->getVendor(), $repository->getName(), $issueNumber);
@@ -114,23 +82,4 @@ public function findStaleIssues(Repository $repository, \DateTimeImmutable $noUp
11482
{
11583
return $this->resultPager->fetchAllLazy($this->searchApi, 'issues', [sprintf('repo:%s is:issue -label:"Keep open" -label:"Missing translations" is:open updated:<%s', $repository->getFullName(), $noUpdateAfter->format('Y-m-d')), 'updated', 'desc']);
11684
}
117-
118-
public function getUsers(Repository $repository, $issueNumber): array
119-
{
120-
$timeline = $this->timelineApi->all($repository->getVendor(), $repository->getName(), $issueNumber);
121-
$users = [];
122-
foreach ($timeline as $event) {
123-
$users[] = $event['actor']['login'] ?? $event['user']['login'] ?? $event['author']['email'] ?? '';
124-
if (isset($event['body'])) {
125-
// Parse body for user reference
126-
if (preg_match_all('|@([a-zA-z_\-0-9]+)|', $event['body'], $matches)) {
127-
foreach ($matches[1] as $match) {
128-
$users[] = $match;
129-
}
130-
}
131-
}
132-
}
133-
134-
return array_map(function ($a) { return strtolower($a); }, array_unique($users));
135-
}
13685
}

src/Api/Issue/IssueApi.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public function show(Repository $repository, $issueNumber): array;
2121

2222
public function commentOnIssue(Repository $repository, $issueNumber, string $commentBody);
2323

24-
public function hasActivity(Repository $repository, $number): bool;
25-
2624
public function lastCommentWasMadeByBot(Repository $repository, $number): bool;
2725

2826
public function findStaleIssues(Repository $repository, \DateTimeImmutable $noUpdateAfter): iterable;
@@ -31,9 +29,4 @@ public function findStaleIssues(Repository $repository, \DateTimeImmutable $noUp
3129
* Close an issue or a pull request.
3230
*/
3331
public function close(Repository $repository, $issueNumber);
34-
35-
/**
36-
* Get users active or mentioned in this issue/pull request.
37-
*/
38-
public function getUsers(Repository $repository, $issueNumber): array;
3932
}

src/Api/Issue/NullIssueApi.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ public function commentOnIssue(Repository $repository, $issueNumber, string $com
1919
{
2020
}
2121

22-
public function hasActivity(Repository $repository, $number): bool
23-
{
24-
return false;
25-
}
26-
2722
public function lastCommentWasMadeByBot(Repository $repository, $number): bool
2823
{
2924
return false;
@@ -37,9 +32,4 @@ public function findStaleIssues(Repository $repository, \DateTimeImmutable $noUp
3732
public function close(Repository $repository, $issueNumber)
3833
{
3934
}
40-
41-
public function getUsers(Repository $repository, $issueNumber): array
42-
{
43-
return [];
44-
}
4535
}

src/Api/Issue/StdErrIssueApi.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Api/PullRequest/GithubPullRequestApi.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,20 @@
44

55
use App\Model\Repository;
66
use Github\Api\PullRequest;
7-
use Github\Api\Repo;
87
use Github\Api\Search;
98

109
/**
1110
* @author Tobias Nyholm <[email protected]>
1211
*/
1312
class GithubPullRequestApi implements PullRequestApi
1413
{
15-
private $github;
1614
private $pullRequest;
1715
private $search;
18-
private $botUsername;
1916

20-
public function __construct(Repo $github, PullRequest $pullRequest, Search $search, string $botUsername)
17+
public function __construct(PullRequest $pullRequest, Search $search)
2118
{
22-
$this->github = $github;
2319
$this->pullRequest = $pullRequest;
2420
$this->search = $search;
25-
$this->botUsername = $botUsername;
2621
}
2722

2823
public function show(Repository $repository, $number): array
@@ -41,18 +36,6 @@ public function updateTitle(Repository $repository, $number, string $title, stri
4136
$this->pullRequest->update($repository->getVendor(), $repository->getName(), $number, $params);
4237
}
4338

44-
/**
45-
* Trigger start of a "find reviewer" job. The job runs on github actions and will comment on the PR.
46-
*/
47-
public function findReviewer(Repository $repository, $number, string $type)
48-
{
49-
$this->github->dispatch($this->botUsername, 'carsonbot', 'find-reviewer', [
50-
'repository' => $repository->getFullName(),
51-
'pull_request_number' => $number,
52-
'type' => $type,
53-
]);
54-
}
55-
5639
public function getAuthorCount(Repository $repository, string $author): int
5740
{
5841
$result = $this->search->issues(sprintf('is:pr repo:%s author:%s', $repository->getFullName(), $author));

src/Api/PullRequest/NullPullRequestApi.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ public function updateTitle(Repository $repository, $number, string $title, stri
2020
{
2121
}
2222

23-
public function findReviewer(Repository $repository, $number, string $type)
24-
{
25-
}
26-
2723
public function getAuthorCount(Repository $repository, string $author): int
2824
{
2925
return 1;

0 commit comments

Comments
 (0)