Skip to content

Commit

Permalink
fix: remove auto request reviewers
Browse files Browse the repository at this point in the history
The auto request reviewers feature never really worked well. The problem
is that it tries to copy the current open review requests, but when a PR
is merged, most of those reviews have already been completed. When
completed, they are no longer in the review request list.

The feature became problematic for users when using a bot user (PAT)
that does not have admin rights to the repository. Those rights are
necessary to request reviewers in some repos.

Multiple solutions were possible, but as this feature doesn't behave
as wanted, and might even be unexpected to some users (breaking the
principle of least astonishment), I believe it should simply be removed.
We can always re-introduce it with a configuration option at a later
time.
  • Loading branch information
korthout committed May 23, 2022
1 parent bc78cfb commit 04324b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
40 changes: 1 addition & 39 deletions src/backport.ts
@@ -1,11 +1,7 @@
import * as core from "@actions/core";
import dedent from "dedent";

import {
CreatePullRequestResponse,
RequestReviewersResponse,
PullRequest,
} from "./github";
import { CreatePullRequestResponse, PullRequest } from "./github";
import { GithubApi } from "./github";
import * as git from "./git";
import * as utils from "./utils";
Expand Down Expand Up @@ -56,7 +52,6 @@ export class Backport {
const headref = mainpr.head.sha;
const baseref = mainpr.base.sha;
const labels = mainpr.labels;
const reviewers = mainpr.requested_reviewers?.map((r) => r.login) ?? [];

console.log(
`Detected labels on PR: ${labels.map((label) => label.name)}`
Expand Down Expand Up @@ -171,27 +166,6 @@ export class Backport {
}
const new_pr = new_pr_response.data;

const review_response = await this.github.requestReviewers({
owner,
repo,
pull_number: new_pr.number,
reviewers,
});
if (review_response.status != 201) {
console.error(JSON.stringify(review_response));
const message = this.composeMessageForRequestReviewersFailed(
review_response,
target
);
await this.github.createComment({
owner,
repo,
issue_number: pull_number,
body: message,
});
continue;
}

const message = this.composeMessageForSuccess(new_pr.number, target);
await this.github.createComment({
owner,
Expand Down Expand Up @@ -285,18 +259,6 @@ export class Backport {
(see action log for full response)`;
}

private composeMessageForRequestReviewersFailed(
response: RequestReviewersResponse,
target: string
): string {
return dedent`${this.composeMessageForSuccess(response.data.number, target)}
But, request reviewers was rejected with status ${
response.status
}.
(see action log for full response)`;
}

private composeMessageForSuccess(pr_number: number, target: string) {
return dedent`Successfully created backport PR #${pr_number} for \`${target}\`.`;
}
Expand Down
10 changes: 1 addition & 9 deletions src/test/backport.test.ts
Expand Up @@ -110,7 +110,7 @@ describe("the backport action", () => {
config.pwd
);
});
it("creates a pull request and requests reviewers", async () => {
it("creates a pull request", async () => {
mockedGit.push.mockResolvedValue(0);
await backport.run();
expect(
Expand All @@ -124,14 +124,6 @@ describe("the backport action", () => {
body: `Backport of #1347 to \`stable/0.25\`.`,
maintainer_can_modify: true,
});
expect(
mockedDefaultGithubWithBackportLabel.requestReviewers
).toHaveBeenCalledWith({
owner: "octocat",
repo: "Hello-World",
pull_number: 9000,
reviewers: ["other_user"],
});
});
});
});
Expand Down

0 comments on commit 04324b4

Please sign in to comment.