Skip to content

Commit

Permalink
Don't re-review when new commits are pushed (#214)
Browse files Browse the repository at this point in the history
It is possible to require re-reviews when new commits are pushed via
branch protection rules, but when that setting is enabled existing
reviews are transitioned to `DISMISSED`, so we should already handle
that case with the `state === "APPROVED"` check.
  • Loading branch information
Harry Marr authored Mar 9, 2023
1 parent aa8a692 commit 0902bf8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions src/approve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,6 @@ test("when a review is commented", async () => {
expect(createReview.isDone()).toBe(true);
});

test("when an old commit has already been approved", async () => {
apiMocks.getUser();
apiMocks.getPull();
apiMocks.getReviews(200, [
{
user: { login: "hmarr" },
commit_id: "6a9ec7556f0a7fa5b49527a1eea4878b8a22d2e0",
state: "APPROVED",
},
]);
const createReview = apiMocks.createReview();

await approve("gh-tok", ghContext());

expect(createReview.isDone()).toBe(true);
});

test("when a review has already been approved by another user", async () => {
apiMocks.getUser();
apiMocks.getPull();
Expand Down
3 changes: 1 addition & 2 deletions src/approve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export async function approve(
core.info(`Commit SHA is ${prHead}`);

const alreadyReviewed = reviews.some(
({ user, commit_id, state }) =>
user?.login === login && commit_id == prHead && state === "APPROVED"
({ user, state }) => user?.login === login && state === "APPROVED"
);
const outstandingReviewRequest = pr.requested_reviewers?.some(
(reviewer) => reviewer.login == login
Expand Down

0 comments on commit 0902bf8

Please sign in to comment.