fix: Determine need_rebase as not a mergeable status#5867
Merged
lukemassa merged 8 commits intorunatlantis:mainfrom Oct 9, 2025
Merged
fix: Determine need_rebase as not a mergeable status#5867lukemassa merged 8 commits intorunatlantis:mainfrom
lukemassa merged 8 commits intorunatlantis:mainfrom
Conversation
randrusiak
reviewed
Oct 7, 2025
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
0747032 to
2b91fea
Compare
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
8b58836 to
766e531
Compare
chenrui333
previously approved these changes
Oct 8, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where GitLab merge requests with need_rebase status were incorrectly considered mergeable, when they should be marked as not mergeable for certain GitLab project configurations.
- Updates the
gitlabIsMergeablefunction to excludeneed_rebasefrom mergeable statuses - Adds comprehensive test cases to handle version differences (pre and post GitLab 15.6)
- Updates documentation to clarify GitLab mergeability requirements
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| server/events/vcs/gitlab_client.go | Removes need_rebase from the list of mergeable statuses |
| server/events/vcs/gitlab_client_test.go | Fixes test structure and adds new test cases for different GitLab versions |
| runatlantis.io/docs/command-requirements.md | Updates documentation to clarify GitLab merge requirements |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
chenrui333
approved these changes
Oct 9, 2025
ramonvermeulen
pushed a commit
to bschaatsbergen/atlantis
that referenced
this pull request
Oct 13, 2025
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ramon Vermeulen <ramonvermeulen98@gmail.com>
dimisjim
pushed a commit
to dimisjim/atlantis
that referenced
this pull request
Oct 29, 2025
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: dimisjim <dimitris.moraitidis@gmail.com>
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.
what
In Gitlab, make it so if a merge request is in status
needs_rebase, then mark it as not mergeable.why
Previously, when an MR was determined to be in the
need_rebasestatus, we counted it as "mergeable", see #4402. Since then a number of bugs have been reported (#5826, #4025, #5124), indicating that users expect certain situations withneed_rebaseto be considered not mergeable.I dug in a bit, and it looks like it depends on how you have your project configured. If your Merge Method is set to "Merge commit with semi-linear history" or "Fast-forward merge", then gitlab is explicitly saying your MR is not able to be merged like so:
Indeed, if you successfully
applyand have automerge set, it will fail to merge, leaving you in a bad state.The VCS itself pretty clearly indicates that a given MR is "unmergeable" we should follow suit
tests
I added some tests, and also tried this out on a test repo by setting a
plan_requirementtomergeableand pushing a stale branch. You'll note that gitlab has noted the MR is not able to be merged, which is reflected in the new error message in the comment.Note also that, even in newer versions, the API can respond with:
merge_statuswas deprecated in 15.6 https://gitlab.com/gitlab-org/gitlab/-/issues/3169#note_1162532204; our code already detects version and uses detailed_merge_status if the server is new enough. However if it's not new enough we have to fall back tomerge_statusand we have no choice but to call such an MR "mergeable". This is reflected in the unit tests.Note also that the unit tests were a bit broken; they included
gitlabVersionsin the test struct but never used it, always used the variablegitlabServerVersions. I fixed this and it allowed me to test different behavior for different versions (presumably) as intended.references
closes: #5826, #4025, and #5124
functionally reverts: #4402