Auto-approve force-pushes if PR was already approved

In our repository, the “Dismiss stale pull request approvals when new commits are pushed” option is enabled.

However, it often happens that you need to rebase your branch to the head of master, or maybe squash commits or change commit messages.  If you do this and then force-push to your branch, reviews are dismissed and you need to get a new review.

Is there a way to set up the repository such that force-pushes do not dismiss reviews as long as the code diff is the same?  If this option is not available in core GitHub, how could a webhook be set up to do it?

7 Likes

HI @sffc,

Thanks for taking the time to write about this behavior, currently there is not a setting on core to accomplish what you’d like; you might investigate using Probot to build an app that might be able to automate this.

We are always looking for ways to improve GitHub and you can rest assured I’ll take your feedback to the appropriate teams.

Best,

Andrea

@andreagriffiths11  You say:

… rest assured I’ll take your feedback to the appropriate teams.

Is this now on the roadmap for Github development? If so when is the expected implementation date?

5 Likes

Any news on this?

1 Like

Also curious if there is any progress on this.

There are always a few small changes after a PR is approved, and right now any change (squash commits, change commit message, etc) will dismiss.

Would be better, as OP suggested, if this applied only when the diff changed.

1 Like

Bumping this. I expect all my devs to rebase frequently, so dismissing approvals for code changes when the diff didn’t actually change seems counterproductive. This option is so close to what I typically want for my teams… force ALL code to be reviewed before merging (which is great for things like SOX compliance), but dismissing those approvals when the code didn’t actually change (just the history) prevents us from turning this on.

Without this option checked, we still have the problem of people force-pushing new code after the required approvals, and that new code will likely never be reviewed.