@@ -107,14 +107,8 @@ func GetDefaultMergeMessage(ctx context.Context, baseGitRepo *git.Repository, pr
107
107
vars ["ClosingIssues" ] = ""
108
108
}
109
109
}
110
-
111
- templateDetail := ""
112
- if splits := strings .SplitN (templateContent , "\n " , 2 ); len (splits ) == 2 {
113
- templateContent = splits [0 ]
114
- templateDetail = splits [1 ]
115
- }
116
- mapping := func (s string ) string { return vars [s ] }
117
- return os .Expand (templateContent , mapping ), os .Expand (templateDetail , mapping ), nil
110
+ message , detail := expandDefaultMergeMessage (templateContent , vars )
111
+ return message , detail , nil
118
112
}
119
113
}
120
114
@@ -134,6 +128,17 @@ func GetDefaultMergeMessage(ctx context.Context, baseGitRepo *git.Repository, pr
134
128
return fmt .Sprintf ("Merge pull request '%s' (%s%d) from %s:%s into %s" , pr .Issue .Title , issueReference , pr .Issue .Index , pr .HeadRepo .FullName (), pr .HeadBranch , pr .BaseBranch ), "" , nil
135
129
}
136
130
131
+ func expandDefaultMergeMessage (template string , vars map [string ]string ) (string , string ) {
132
+ message := strings .TrimSpace (template )
133
+ detail := ""
134
+ if splits := strings .SplitN (message , "\n " , 2 ); len (splits ) == 2 {
135
+ message = splits [0 ]
136
+ detail = strings .TrimSpace (detail )
137
+ }
138
+ mapping := func (s string ) string { return vars [s ] }
139
+ return os .Expand (message , mapping ), os .Expand (detail , mapping )
140
+ }
141
+
137
142
// Merge merges pull request to base repository.
138
143
// Caller should check PR is ready to be merged (review and status checks)
139
144
func Merge (ctx context.Context , pr * issues_model.PullRequest , doer * user_model.User , baseGitRepo * git.Repository , mergeStyle repo_model.MergeStyle , expectedHeadCommitID , message string , wasAutoMerged bool ) error {
0 commit comments