-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix prematurely merging PR after update #242
Fix prematurely merging PR after update #242
Conversation
After my changes in palantir#235, I noticed that sometimes a PR is updated and then merged as part of the same webhook request, before the required statuses are fulfilled. This is because bulldozer was still using the stale statuses from before the update was performed.
8de2c60
to
a1d96ec
Compare
@bluekeyes sorry for the bother, I'd love your thoughts on this when you have a chance. It's a pretty big deal for us to make sure that all checks are passing after integrating the latest version of the main branch before merging and I'm hoping to get this bug fix into our environment ASAP. |
I think this change makes sense, but I'd like to understand more about the situation where it happens. Specifically, I want to understand if this is a normal thing that happens in certain conditions or if Bulldozer is racing against GitHub and catching an open merge window that we expected GitHub to prevent. I think an example of your branch protection settings, Bulldozer settings, and sequence of events that led to one of these merges would help. For instance, do you have branch protection set to enforce that branches must be up-to-date before merging? |
Sounds good! For branch protection settings, the people that can merge to main are limited to a specific group of people. PRs are not required to be up to date with Bulldozer configuration is set to both update and merge when the What I've seen happen is that, given a PR that is behind This happens in the following code: bulldozer/server/handler/pull_request.go Lines 72 to 81 in 19a4b08
You can see how after Does that make sense? |
Thanks, this all makes sense to me. The situation you described is basically the only one I could think of, so it's good to have confirmation that this is what's happening. If PRs are required to be up-to-date in branch protection, then I expect GitHub to return an error when Bulldozer attempts to merge the just-updated PR. Bulldozer detects and ignores this error and waits for future events, which would most likely be for the status checks on the update commit. |
Thank you!
That's interesting. I was actually expecting GitHub to allow the merge, since Bulldozer had (just) previously updated it. |
After my changes in #235, I noticed that sometimes a PR is updated and then merged as part of the same webhook request, before the required statuses are fulfilled. This is because bulldozer was still using the stale statuses from before the update was performed.
This change skips the merge if the PR was updated to avoid using the stale PR status.