Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make Github un-approve a pull request if a new commit is pushed to the branch?

Tags:

github

Using the new pull request approval process in Github, if I approve a PR but then a dev pushes a new commit to that branch I'd want the PR to go back to the state it is in to start with (i.e. not approved).

At the moment it stays green but in reality there is code that hasn't been reviewed in the branch.

like image 940
Force Hero Avatar asked Nov 09 '16 11:11

Force Hero


People also ask

How do I undo a GitHub approval?

On the "Conversation" tab, scroll to the review you'd like to dismiss, then click . Click , then click Dismiss review. Type your reason for dismissing the review, then click Dismiss review.

Can I update pull request with new commit?

As long as the pull request is still open, it should get updated with any added commits automatically.

Can you cancel a pull request in GitHub?

Under your repository name, click Pull requests. In the "Pull Requests" list, click the pull request you'd like to close. At the bottom of the pull request, below the comment box, click Close pull request. Optionally, delete the branch.


2 Answers

On GitHub, navigate to the main page of the repository. Under your repository name, click Settings. In the left menu, click Branches. Select the branch you want to restrict using the drop-down menu.

Select Dismiss stale pull request approvals when new commits are pushed.

enter image description here

This dismisses a pull request approval review when a code-modifying commit is pushed to the branch.

Click Save changes.

Ref: https://help.github.com/articles/enabling-required-reviews-for-pull-requests/

like image 87
Ε Г И І И О Avatar answered Sep 21 '22 19:09

Ε Г И І И О


It's not clear from your question if you need this automatically done, or if a manual process is okay too.

In my case a manual solution was fine. We'll just rely on developers to use their judgment on whether a PR should be unapproved.

To manually unapprove a PR, you can go to the comments section where the approval is, and click "show all reviewers". Then choose Dismiss for each approved review.

like image 39
Chris Garrett Avatar answered Sep 19 '22 19:09

Chris Garrett