1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-19 23:28:14 +00:00

Avoid amending the Rebase and Fast-forward merge if there is no message template () ()

Backport  by @wxiaoguang

Related . Close 

After the fix:


![image](https://github.com/go-gitea/gitea/assets/2114189/0e900927-ea72-4f8f-bde6-5ed927cb02f4)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot 2023-07-10 06:23:54 -04:00 committed by GitHub
parent d713cf6150
commit a1bc2aa05e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions
models/repo
services/pull

View file

@ -11,7 +11,7 @@ type MergeStyle string
const ( const (
// MergeStyleMerge create merge commit // MergeStyleMerge create merge commit
MergeStyleMerge MergeStyle = "merge" MergeStyleMerge MergeStyle = "merge"
// MergeStyleRebase rebase before merging // MergeStyleRebase rebase before merging, and fast-forward
MergeStyleRebase MergeStyle = "rebase" MergeStyleRebase MergeStyle = "rebase"
// MergeStyleRebaseMerge rebase before merging with merge commit (--no-ff) // MergeStyleRebaseMerge rebase before merging with merge commit (--no-ff)
MergeStyleRebaseMerge MergeStyle = "rebase-merge" MergeStyleRebaseMerge MergeStyle = "rebase-merge"

View file

@ -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. // Squash merge has a different from other styles.
if mergeStyle == repo_model.MergeStyleSquash { if mergeStyle == repo_model.MergeStyleSquash {
return fmt.Sprintf("%s (%s%d)", pr.Issue.Title, issueReference, pr.Issue.Index), "", nil return fmt.Sprintf("%s (%s%d)", pr.Issue.Title, issueReference, pr.Issue.Index), "", nil