feat(gitprovider/gitlab): Support for squash merge and fast forward#5454
Closed
aslafy-z wants to merge 2 commits intoakuity:mainfrom
Closed
feat(gitprovider/gitlab): Support for squash merge and fast forward#5454aslafy-z wants to merge 2 commits intoakuity:mainfrom
aslafy-z wants to merge 2 commits intoakuity:mainfrom
Conversation
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
hiddeco
reviewed
Dec 6, 2025
Member
|
@fuskovic because of your familiarity with all the webhook receivers, I'd like you to look at this PR as well, please. Please consult the GitLab docs and/or experiment a bit with their API to verify this is indeed how things work on their end. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5454 +/- ##
==========================================
+ Coverage 55.35% 55.36% +0.01%
==========================================
Files 430 430
Lines 31851 31861 +10
==========================================
+ Hits 17631 17641 +10
Misses 13214 13214
Partials 1006 1006 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fuskovic
reviewed
Dec 12, 2025
fuskovic
requested changes
Dec 12, 2025
Member
fuskovic
left a comment
There was a problem hiding this comment.
I think some additional context in the comments for the future-proofing behavior could be useful.
d1c2bad to
f421a77
Compare
fuskovic
reviewed
Dec 12, 2025
Signed-off-by: Zadkiel AHARONIAN <hello@zadkiel.fr>
fuskovic
reviewed
Dec 12, 2025
Signed-off-by: Zadkiel AHARONIAN <hello@zadkiel.fr>
Member
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.
Currently,
gitprovider.PullRequest.MergeCommitSHAis set only fromglMR.MergeCommitSHAby the GitLab provider.This works for merge strategies that create a merge commit, but it breaks for repositories configured to use fast-forward merges without a merge commit: in those cases, the commit information stays empty even though the merge request is successfully merged.
GitLab’s API exposes three relevant fields on merge requests:
merge_commit_sha: SHA of the merge commit (when one exists).squash_commit_sha: SHA of the squash commit.sha: SHA of the head commit in the source branch.According to the documentation, a squashed merge is supposed to populate
squash_commit_sha, and (depending on merge method) may or may not create a merge commit. However, there are known inconsistencies in GitLab’s current implementation:merge_commit_shawith the squashed commit and leavesquash_commit_shaunset in the webhook payloads.squash_commit_shaand to fix related webhook behavior.See:
To handle both the current behavior and the intended future behavior, this PR updates
convertGitlabMRto compute an “effective merge commit SHA” only when the merge request is in themergedstate, using the following precedence:glMR.MergeCommitSHAif it is setmerge_commit_sha.glMR.SquashCommitSHAifMergeCommitSHAis empty butSquashCommitSHAis setglMR.SHAif bothMergeCommitSHAandSquashCommitSHAare emptyFor unmerged merge requests,
MergeCommitSHAremains empty.This makes the GitLab provider resilient to both current and future GitLab implementations while ensuring
MergeCommitSHAaccurately reflects the commit that actually landed on the target branch for merged requests.