Skip to content

Commit

Permalink
Avoid amending the Rebase and Fast-forward merge if there is no messa…
Browse files Browse the repository at this point in the history
…ge template (#25779) (#25809)

Backport #25779 by @wxiaoguang

Related #22669. Close #25177

After the fix:


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

Co-authored-by: wxiaoguang <[email protected]>
  • Loading branch information
GiteaBot and wxiaoguang authored Jul 10, 2023
1 parent d713cf6 commit a1bc2aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion models/repo/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions services/pull/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1bc2aa

Please sign in to comment.