mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-02-07 10:17:02 +00:00
fix(gitlab): release not created when release pr was squashed
When the release pull request was squashed on GitLab, the release
creation fails with error
Error: failed to create pending releases: pull request is missing the merge commit
This fixes the problem by checking both `MergeCommitSHA` and
`SquashCommitSHA` and using whichever is set.
This commit is contained in:
parent
763018ff9b
commit
abea112ec6
1 changed files with 5 additions and 2 deletions
|
|
@ -176,8 +176,8 @@ func (g *GitLab) prForCommit(ctx context.Context, commit git.Commit) (*git.PullR
|
||||||
|
|
||||||
var mergeRequest *gitlab.MergeRequest
|
var mergeRequest *gitlab.MergeRequest
|
||||||
for _, mr := range associatedMRs {
|
for _, mr := range associatedMRs {
|
||||||
// We only look for the MR that has this commit set as the "merge commit" => The result of squashing this branch onto main
|
// 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 {
|
if mr.MergeCommitSHA == commit.Hash || mr.SquashCommitSHA == commit.Hash {
|
||||||
mergeRequest = mr
|
mergeRequest = mr
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -387,9 +387,12 @@ func gitlabMRToReleasePullRequest(pr *gitlab.MergeRequest) *releasepr.ReleasePul
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Commit SHA is saved in either [MergeCommitSHA] or [SquashCommitSHA] depending on which merge method was used.
|
||||||
var releaseCommit *git.Commit
|
var releaseCommit *git.Commit
|
||||||
if pr.MergeCommitSHA != "" {
|
if pr.MergeCommitSHA != "" {
|
||||||
releaseCommit = &git.Commit{Hash: pr.MergeCommitSHA}
|
releaseCommit = &git.Commit{Hash: pr.MergeCommitSHA}
|
||||||
|
} else if pr.SquashCommitSHA != "" {
|
||||||
|
releaseCommit = &git.Commit{Hash: pr.SquashCommitSHA}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &releasepr.ReleasePullRequest{
|
return &releasepr.ReleasePullRequest{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue