From 716add7a3703f8252b3fd41973fcd27f9a203233 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Tue, 2 Aug 2022 14:56:30 +0800 Subject: [PATCH 1/3] Add Commit message to PR --- templates/repo/issue/view_content/pull.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 59e0962d1795d..6ac989cdec75c 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -343,7 +343,7 @@ (() => { const defaultMergeTitle = {{.DefaultMergeMessage}}; const defaultSquashMergeTitle = {{.DefaultSquashMergeMessage}}; - const defaultMergeMessage = 'Reviewed-on: ' + {{$.Issue.HTMLURL}} + '\n' + {{$approvers}}; + const defaultMergeMessage = {{.GetCommitMessages}} + 'Reviewed-on: ' + {{$.Issue.HTMLURL}} + '\n' + {{$approvers}}; const mergeForm = { 'baseLink': {{.Link}}, 'textCancel': {{$.locale.Tr "cancel"}}, From 269868566173cddeba24c8117fef2689fd93c5c6 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 3 Aug 2022 00:16:20 +0800 Subject: [PATCH 2/3] make sure GetCommitMessages always exists because the template needs it --- routers/web/repo/pull.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 2a961c3cbc554..7c140a4e5991e 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -510,6 +510,8 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C return nil } ctx.Data["GetCommitMessages"] = pull_service.GetSquashMergeCommitMessages(ctx, pull) + } else { + ctx.Data["GetCommitMessages"] = "" } sha, err := baseGitRepo.GetRefCommitID(pull.GetGitRefName()) From 5e5e23f3ab5db7f2320518a78187d8ae23fd2e09 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 3 Aug 2022 01:27:15 +0800 Subject: [PATCH 3/3] the commit messages should only be used for squash merge --- templates/repo/issue/view_content/pull.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 6ac989cdec75c..fd901f013ebdb 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -343,7 +343,7 @@ (() => { const defaultMergeTitle = {{.DefaultMergeMessage}}; const defaultSquashMergeTitle = {{.DefaultSquashMergeMessage}}; - const defaultMergeMessage = {{.GetCommitMessages}} + 'Reviewed-on: ' + {{$.Issue.HTMLURL}} + '\n' + {{$approvers}}; + const defaultMergeMessage = 'Reviewed-on: ' + {{$.Issue.HTMLURL}} + '\n' + {{$approvers}}; const mergeForm = { 'baseLink': {{.Link}}, 'textCancel': {{$.locale.Tr "cancel"}}, @@ -395,7 +395,7 @@ 'allowed': {{$prUnit.PullRequestsConfig.AllowSquash}}, 'textDoMerge': {{$.locale.Tr "repo.pulls.squash_merge_pull_request"}}, 'mergeTitleFieldText': defaultSquashMergeTitle, - 'mergeMessageFieldText': defaultMergeMessage, + 'mergeMessageFieldText': {{.GetCommitMessages}} + defaultMergeMessage, 'hideAutoMerge': generalHideAutoMerge, }, {