diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-07-10 16:12:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-10 10:12:50 +0200 |
commit | d9872797f84f6a81bbed3d19fee536ce2a3aadb6 (patch) | |
tree | 7fc1070a6233f0b8785176a963b56ced30bc7681 | |
parent | d2c3a90ee24f6e9e3ffff164fa7e675a269e5add (diff) | |
download | gitea-d9872797f84f6a81bbed3d19fee536ce2a3aadb6.tar.gz gitea-d9872797f84f6a81bbed3d19fee536ce2a3aadb6.zip |
Avoid amending the Rebase and Fast-forward merge if there is no message template (#25779)
Related #22669. Close #25177
After the fix:
![image](https://github.com/go-gitea/gitea/assets/2114189/0e900927-ea72-4f8f-bde6-5ed927cb02f4)
Co-authored-by: Giteabot <teabot@gitea.io>
-rw-r--r-- | models/repo/git.go | 2 | ||||
-rw-r--r-- | services/pull/merge.go | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/models/repo/git.go b/models/repo/git.go index 7ae88058dc..c1af7ee960 100644 --- a/models/repo/git.go +++ b/models/repo/git.go @@ -11,7 +11,7 @@ type MergeStyle string const ( // MergeStyleMerge create merge commit MergeStyleMerge MergeStyle = "merge" - // MergeStyleRebase rebase before merging + // MergeStyleRebase rebase before merging, and fast-forward MergeStyleRebase MergeStyle = "rebase" // MergeStyleRebaseMerge rebase before merging with merge commit (--no-ff) MergeStyleRebaseMerge MergeStyle = "rebase-merge" diff --git a/services/pull/merge.go b/services/pull/merge.go index 85bb90b853..416c744463 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -110,6 +110,11 @@ func getMergeMessage(ctx context.Context, baseGitRepo *git.Repository, pr *issue } } + if mergeStyle == repo_model.MergeStyleRebase { + // for fast-forward rebase, do not amend the last commit if there is no template + return "", "", nil + } + // Squash merge has a different from other styles. if mergeStyle == repo_model.MergeStyleSquash { return fmt.Sprintf("%s (%s%d)", pr.Issue.Title, issueReference, pr.Issue.Index), "", nil |