From 4cb7dc0275cd2b457f766d9295f2560f3087458a Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Thu, 10 Jul 2025 17:43:04 +0200 Subject: [PATCH] fix(gitlab): support Fast-forward merge This changes allows detecting that the Release Pleaser PR is well merged. As of today, it fails with "2025-07-10T15:24:08Z ERR failed to create pending releases: pull request is missing the merge commit". Failing job: https://gitlab.com/ccl-consulting/fleeting-plugin-scaleway/-/jobs/10639970620 Merged pull request: https://gitlab.com/ccl-consulting/fleeting-plugin-scaleway/-/merge_requests/12 Merged pull request API view: https://gitlab.com/api/v4/projects/70582087/merge_requests/12 Landed commit: https://gitlab.com/ccl-consulting/fleeting-plugin-scaleway/-/commit/29ac598d0bf7952a85f28ac5cf5d3e113069f7ae --- internal/forge/gitlab/gitlab.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/forge/gitlab/gitlab.go b/internal/forge/gitlab/gitlab.go index 06de7fd..f8cec5d 100644 --- a/internal/forge/gitlab/gitlab.go +++ b/internal/forge/gitlab/gitlab.go @@ -193,7 +193,7 @@ func (g *GitLab) prForCommit(ctx context.Context, commit git.Commit) (*git.PullR var mergeRequest *gitlab.BasicMergeRequest for _, mr := range associatedMRs { // We only look for the MR that has this commit set as the "merge/squash commit" => The result of squashing this branch onto main - if mr.MergeCommitSHA == commit.Hash || mr.SquashCommitSHA == commit.Hash { + if mr.MergeCommitSHA == commit.Hash || mr.SquashCommitSHA == commit.Hash || mr.SHA == commit.Hash { mergeRequest = mr break } @@ -403,12 +403,14 @@ func gitlabMRToReleasePullRequest(pr *gitlab.BasicMergeRequest) *releasepr.Relea } } - // Commit SHA is saved in either [MergeCommitSHA] or [SquashCommitSHA] depending on which merge method was used. + // Commit SHA is saved in either [MergeCommitSHA], [SquashCommitSHA] or [SHA] depending on which merge method was used. var releaseCommit *git.Commit if pr.MergeCommitSHA != "" { releaseCommit = &git.Commit{Hash: pr.MergeCommitSHA} } else if pr.SquashCommitSHA != "" { releaseCommit = &git.Commit{Hash: pr.SquashCommitSHA} + } else if pr.MergedAt != nil && pr.SHA != "" { + releaseCommit = &git.Commit{Hash: pr.SHA} } return &releasepr.ReleasePullRequest{