mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-23 03:11:22 +02:00
fix
This commit is contained in:
@@ -1191,7 +1191,7 @@ LEVEL = Info
|
||||
;; Default source for the pull request title when opening a new PR.
|
||||
;; "first-commit" uses the oldest commit's summary.
|
||||
;; "auto" uses commit's summary if the PR only has one commit, normalizes the branch name if multiple commits.
|
||||
;; "branch-name" always uses the normalized branch name.
|
||||
;; "branch-name" always uses the PR's branch name.
|
||||
;DEFAULT_TITLE_SOURCE = auto
|
||||
;;
|
||||
;; Delay mergeable check until page view or API access, for pull requests that have not been updated in the specified days when their base branches get updated.
|
||||
|
||||
@@ -382,9 +382,10 @@ func autoTitleFromBranchName(name string) string {
|
||||
}
|
||||
|
||||
func prepareNewPullRequestTitleContent(ci *git_service.CompareInfo, commits []*git_model.SignCommitWithStatuses, defaultTitleSource string) (title, content string) {
|
||||
useFirstCommitAsTitle := defaultTitleSource != setting.RepoPRTitleSourceBranchName &&
|
||||
(len(commits) == 1 || (defaultTitleSource == setting.RepoPRTitleSourceFirstCommit && len(commits) > 0))
|
||||
if useFirstCommitAsTitle {
|
||||
useFirstCommitAsTitle := len(commits) == 1 || (defaultTitleSource == setting.RepoPRTitleSourceFirstCommit && len(commits) > 0)
|
||||
if defaultTitleSource == setting.RepoPRTitleSourceBranchName {
|
||||
title = ci.HeadRef.ShortName()
|
||||
} else if useFirstCommitAsTitle {
|
||||
// the "commits" are from "ShowPrettyFormatLogToList", which is ordered from newest to oldest, here take the oldest one
|
||||
c := commits[len(commits)-1]
|
||||
title = c.UserCommit.GitCommit.MessageTitle()
|
||||
@@ -392,7 +393,7 @@ func prepareNewPullRequestTitleContent(ci *git_service.CompareInfo, commits []*g
|
||||
title = autoTitleFromBranchName(ci.HeadRef.ShortName())
|
||||
}
|
||||
|
||||
if useFirstCommitAsTitle && len(commits) == 1 {
|
||||
if len(commits) == 1 {
|
||||
c := commits[0]
|
||||
content = c.GitCommit.MessageBody()
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestNewPullRequestTitleContent(t *testing.T) {
|
||||
assert.Empty(t, content)
|
||||
|
||||
title, content = prepareNewPullRequestTitleContent(ci, nil, setting.RepoPRTitleSourceBranchName)
|
||||
assert.Equal(t, "Head branch", title)
|
||||
assert.Equal(t, "head-branch", title)
|
||||
assert.Empty(t, content)
|
||||
|
||||
// single commit
|
||||
@@ -83,10 +83,6 @@ func TestNewPullRequestTitleContent(t *testing.T) {
|
||||
assert.Equal(t, "single-commit-title", title)
|
||||
assert.Equal(t, "body", content)
|
||||
|
||||
title, content = prepareNewPullRequestTitleContent(ci, []*git_model.SignCommitWithStatuses{mockCommit("single-commit-title\nbody")}, setting.RepoPRTitleSourceBranchName)
|
||||
assert.Equal(t, "Head branch", title)
|
||||
assert.Empty(t, content)
|
||||
|
||||
// multiple commits
|
||||
commits := []*git_model.SignCommitWithStatuses{
|
||||
// ordered from newest to oldest
|
||||
|
||||
Reference in New Issue
Block a user