From 3caa7364ee82067742c8fbed1222c7ba0b5ff794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Thu, 17 Oct 2024 19:22:03 +0200 Subject: [PATCH 1/2] 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. --- internal/forge/gitlab/gitlab.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/forge/gitlab/gitlab.go b/internal/forge/gitlab/gitlab.go index f77b324..aedc4f3 100644 --- a/internal/forge/gitlab/gitlab.go +++ b/internal/forge/gitlab/gitlab.go @@ -176,8 +176,8 @@ func (g *GitLab) prForCommit(ctx context.Context, commit git.Commit) (*git.PullR var mergeRequest *gitlab.MergeRequest 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 - if mr.MergeCommitSHA == commit.Hash { + // 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 { mergeRequest = mr 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 if pr.MergeCommitSHA != "" { releaseCommit = &git.Commit{Hash: pr.MergeCommitSHA} + } else if pr.SquashCommitSHA != "" { + releaseCommit = &git.Commit{Hash: pr.SquashCommitSHA} } return &releasepr.ReleasePullRequest{ From 1883466c3e333da89537e4f90889ba1c572972dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Thu, 17 Oct 2024 19:24:24 +0200 Subject: [PATCH 2/2] chore(main): release v0.4.1 (#87) Co-authored-by: releaser-pleaser <> --- CHANGELOG.md | 6 ++++++ action.yml | 2 +- templates/run.yml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3a315d..1f0ad20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 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) ### ✨ Highlights diff --git a/action.yml b/action.yml index 118385a..f07a88b 100644 --- a/action.yml +++ b/action.yml @@ -21,7 +21,7 @@ inputs: outputs: {} runs: 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: - run - --forge=github diff --git a/templates/run.yml b/templates/run.yml index 0531c95..278a59a 100644 --- a/templates/run.yml +++ b/templates/run.yml @@ -24,7 +24,7 @@ releaser-pleaser: # There is no way to run a pipeline when the MR description is updated :( - if: $CI_COMMIT_BRANCH == "$[[ inputs.branch ]]" 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: [""] variables: GITLAB_TOKEN: $[[ inputs.token ]]