fix(code-review): preserve in-flight review on merge commit push#2741
Open
alex-alecu wants to merge 5 commits intomainfrom
Open
fix(code-review): preserve in-flight review on merge commit push#2741alex-alecu wants to merge 5 commits intomainfrom
alex-alecu wants to merge 5 commits intomainfrom
Conversation
When a pull_request.synchronize / merge_request.update event arrives with a merge-commit head (e.g. clicking GitHub's 'Update branch' button), the review was being cancelled before the merge-commit skip check ran, leaving the PR with no active review. Reorder so the merge-commit check runs first and bails out without touching existing reviews. Extract the decision into small pure helpers for unit testing.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Reviewed by gpt-5.4-20260305 · 670,437 tokens |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When someone clicked GitHub's "Update branch" button (or merged main into their feature branch), the code review that was already running on their pull request would disappear. It would get cancelled, and no new review would take its place, leaving the PR with nothing. This made it look like our bot just forgot about the PR.
What changed
The webhook that handles new commits on a pull request now checks whether the new commit is a merge commit before it decides to cancel the running review. If it is a merge commit, the webhook quietly walks away and lets the existing review keep running on the real feature commit, where it is useful. Previously the order was reversed — cancel first, then notice it was a merge commit — which threw the valid review away for no reason. The same fix is applied on the GitLab side for merge requests. Small helper functions were extracted so the decision logic is easy to unit test.
How to test
Visual Changes
N/A
Reviewer Notes
The behaviour only changes in one scenario: a synchronize/update webhook whose head is a merge commit and there is already an in-flight review. All other paths (normal pushes, no prior review, opened/reopened events) are unchanged. The merge-commit detection itself was already in the codebase; this PR only moves it earlier in the handler. Downstream logic that picks the incremental review baseline (
findPreviousCompletedReview) already filters onstatus = 'completed'and benefits automatically from not losing the prior review.