@@ -389,6 +389,7 @@ func ViewIssue(ctx *context.Context) {
389
389
prepareIssueViewSidebarPin ,
390
390
func (ctx * context.Context , issue * issues_model.Issue ) { preparePullViewPullInfo (ctx , issue ) },
391
391
preparePullViewReviewAndMerge ,
392
+ prepareIssueViewSquashMergeMsg ,
392
393
}
393
394
394
395
for _ , prepareFunc := range prepareFuncs {
@@ -442,6 +443,7 @@ func ViewPullMergeBox(ctx *context.Context) {
442
443
}
443
444
preparePullViewPullInfo (ctx , issue )
444
445
preparePullViewReviewAndMerge (ctx , issue )
446
+ prepareIssueViewSquashMergeMsg (ctx , issue )
445
447
ctx .Data ["PullMergeBoxReloading" ] = issue .PullRequest .IsChecking ()
446
448
447
449
// TODO: it should use a dedicated struct to render the pull merge box, to make sure all data is prepared correctly
@@ -928,14 +930,6 @@ func preparePullViewReviewAndMerge(ctx *context.Context, issue *issues_model.Iss
928
930
ctx .Data ["DefaultMergeMessage" ] = defaultMergeMessage
929
931
ctx .Data ["DefaultMergeBody" ] = defaultMergeBody
930
932
931
- defaultSquashMergeMessage , defaultSquashMergeBody , err := pull_service .GetDefaultMergeMessage (ctx , ctx .Repo .GitRepo , pull , repo_model .MergeStyleSquash )
932
- if err != nil {
933
- ctx .ServerError ("GetDefaultSquashMergeMessage" , err )
934
- return
935
- }
936
- ctx .Data ["DefaultSquashMergeMessage" ] = defaultSquashMergeMessage
937
- ctx .Data ["DefaultSquashMergeBody" ] = defaultSquashMergeBody
938
-
939
933
pb , err := git_model .GetFirstMatchProtectedBranchRule (ctx , pull .BaseRepoID , pull .BaseBranch )
940
934
if err != nil {
941
935
ctx .ServerError ("LoadProtectedBranch" , err )
@@ -1006,3 +1000,42 @@ func prepareIssueViewContent(ctx *context.Context, issue *issues_model.Issue) {
1006
1000
return
1007
1001
}
1008
1002
}
1003
+
1004
+ func getIssueViewSquashMergeCommits (ctx * context.Context , issue * issues_model.Issue ) (string , error ) {
1005
+ pull := issue .PullRequest
1006
+ pull .Issue = issue
1007
+
1008
+ baseCommit := GetMergedBaseCommitID (ctx , issue )
1009
+
1010
+ compareInfo , err := ctx .Repo .GitRepo .GetCompareInfo (ctx .Repo .Repository .RepoPath (),
1011
+ baseCommit , pull .GetGitHeadRefName (), false , false )
1012
+ if err != nil {
1013
+ return "" , err
1014
+ }
1015
+
1016
+ commits := ""
1017
+ for _ , c := range compareInfo .Commits {
1018
+ commits += fmt .Sprintf ("* %s\n " , c .CommitMessage )
1019
+ }
1020
+
1021
+ return commits , nil
1022
+ }
1023
+
1024
+ func prepareIssueViewSquashMergeMsg (ctx * context.Context , issue * issues_model.Issue ) {
1025
+ pull := issue .PullRequest
1026
+
1027
+ defaultSquashMergeMessage , defaultSquashMergeBody , err := pull_service .GetDefaultMergeMessage (ctx , ctx .Repo .GitRepo , pull , repo_model .MergeStyleSquash )
1028
+ if err != nil {
1029
+ ctx .ServerError ("GetDefaultSquashMergeMessage" , err )
1030
+ return
1031
+ }
1032
+
1033
+ commitsMsg , err := getIssueViewSquashMergeCommits (ctx , issue )
1034
+ if err != nil {
1035
+ ctx .ServerError ("getIssueViewSquashMergeCommits" , err )
1036
+ return
1037
+ }
1038
+
1039
+ ctx .Data ["DefaultSquashMergeMessage" ] = defaultSquashMergeMessage
1040
+ ctx .Data ["DefaultSquashMergeBody" ] = fmt .Sprintf ("--------------------\n %s\n %s" , commitsMsg , defaultSquashMergeBody )
1041
+ }
0 commit comments