@@ -389,6 +389,7 @@ func ViewIssue(ctx *context.Context) {
389389 prepareIssueViewSidebarPin ,
390390 func (ctx * context.Context , issue * issues_model.Issue ) { preparePullViewPullInfo (ctx , issue ) },
391391 preparePullViewReviewAndMerge ,
392+ prepareIssueViewSquashMergeMsg ,
392393 }
393394
394395 for _ , prepareFunc := range prepareFuncs {
@@ -442,6 +443,7 @@ func ViewPullMergeBox(ctx *context.Context) {
442443 }
443444 preparePullViewPullInfo (ctx , issue )
444445 preparePullViewReviewAndMerge (ctx , issue )
446+ prepareIssueViewSquashMergeMsg (ctx , issue )
445447 ctx .Data ["PullMergeBoxReloading" ] = issue .PullRequest .IsChecking ()
446448
447449 // 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
928930 ctx .Data ["DefaultMergeMessage" ] = defaultMergeMessage
929931 ctx .Data ["DefaultMergeBody" ] = defaultMergeBody
930932
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-
939933 pb , err := git_model .GetFirstMatchProtectedBranchRule (ctx , pull .BaseRepoID , pull .BaseBranch )
940934 if err != nil {
941935 ctx .ServerError ("LoadProtectedBranch" , err )
@@ -1006,3 +1000,42 @@ func prepareIssueViewContent(ctx *context.Context, issue *issues_model.Issue) {
10061000 return
10071001 }
10081002}
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