Compare commits

...

2 commits

Author SHA1 Message Date
1883466c3e
chore(main): release v0.4.1 (#87)
Co-authored-by: releaser-pleaser <>
2024-10-17 19:24:24 +02:00
3caa7364ee
fix(gitlab): release not created when release pr was squashed (#86)
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.
2024-10-17 17:22:03 +00:00
4 changed files with 13 additions and 4 deletions

View file

@ -1,5 +1,11 @@
# Changelog # Changelog
## [v0.4.1](https://github.com/apricote/releaser-pleaser/releases/tag/v0.4.1)
### Bug Fixes
- **gitlab**: release not created when release pr was squashed (#86)
## [v0.4.0](https://github.com/apricote/releaser-pleaser/releases/tag/v0.4.0) ## [v0.4.0](https://github.com/apricote/releaser-pleaser/releases/tag/v0.4.0)
### ✨ Highlights ### ✨ Highlights

View file

@ -21,7 +21,7 @@ inputs:
outputs: {} outputs: {}
runs: runs:
using: 'docker' using: 'docker'
image: ghcr.io/apricote/releaser-pleaser:v0.4.0 # x-releaser-pleaser-version image: ghcr.io/apricote/releaser-pleaser:v0.4.1 # x-releaser-pleaser-version
args: args:
- run - run
- --forge=github - --forge=github

View file

@ -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{

View file

@ -24,7 +24,7 @@ releaser-pleaser:
# There is no way to run a pipeline when the MR description is updated :( # There is no way to run a pipeline when the MR description is updated :(
- if: $CI_COMMIT_BRANCH == "$[[ inputs.branch ]]" - if: $CI_COMMIT_BRANCH == "$[[ inputs.branch ]]"
image: image:
name: ghcr.io/apricote/releaser-pleaser:v0.4.0 # x-releaser-pleaser-version name: ghcr.io/apricote/releaser-pleaser:v0.4.1 # x-releaser-pleaser-version
entrypoint: [""] entrypoint: [""]
variables: variables:
GITLAB_TOKEN: $[[ inputs.token ]] GITLAB_TOKEN: $[[ inputs.token ]]