@@ -145,6 +145,18 @@ func (m *Message) buildFooter(
145
145
hostname , duration .Round (time .Second ), pkg .GitCommit , envStr , appsChecked , totalChecked )
146
146
}
147
147
148
+ type BuildCommentParams struct {
149
+ Start time.Time
150
+ CommitSHA string
151
+ LabelFilter string
152
+ ShowDebugInfo bool
153
+ Identifier string
154
+ AppsChecked int
155
+ TotalChecked int
156
+ MaxCommentLength int
157
+ PrLinkTemplate string
158
+ }
159
+
148
160
// BuildComment iterates the map of all apps in this message, building a final comment from their current state
149
161
//
150
162
// This function is responsible for generating the VCS comment(s) for a PR/MR, handling:
@@ -182,8 +194,7 @@ func (m *Message) buildFooter(
182
194
//
183
195
// The output is a slice of strings, each representing a comment chunk to be posted.
184
196
func (m * Message ) BuildComment (
185
- ctx context.Context , start time.Time , commitSHA , labelFilter string , showDebugInfo bool , identifier string ,
186
- appsChecked , totalChecked int , maxCommentLength int , prLinkTemplate string ,
197
+ ctx context.Context , params BuildCommentParams ,
187
198
) []string {
188
199
_ , span := tracer .Start (ctx , "buildComment" )
189
200
defer span .End ()
@@ -192,14 +203,14 @@ func (m *Message) BuildComment(
192
203
names := getSortedKeys (m .apps )
193
204
194
205
// Header for the first comment
195
- header := pkg .GetMessageHeader (identifier )
206
+ header := pkg .GetMessageHeader (params . Identifier )
196
207
// Footer warning for split comments
197
208
splitCommentFooter := "\n \n > **Warning**: Output length greater than maximum allowed comment size. Continued in next comment"
198
209
// Header for continued comments
199
210
// this is written from the VCS PostMessage/UpdateMessage function. So, we need to account for it here
200
- continuedHeader := fmt .Sprintf ("%s> Continued from previous [comment](%s)\n \n " , header , prLinkTemplate )
211
+ continuedHeader := fmt .Sprintf ("%s> Continued from previous [comment](%s)\n \n " , header , params . PrLinkTemplate )
201
212
// Max content length for each chunk (accounting for continuedHeader)
202
- maxContentLength := maxCommentLength - len (continuedHeader ) - 10 // 10 is a safety margin
213
+ maxContentLength := params . MaxCommentLength - len (continuedHeader ) - 10 // 10 is a safety margin
203
214
contentLength := 0
204
215
205
216
comments := []string {}
@@ -359,12 +370,12 @@ func (m *Message) BuildComment(
359
370
}
360
371
361
372
// Add the footer (with debug info if requested)
362
- footer := m .buildFooter (start , commitSHA , labelFilter , showDebugInfo , appsChecked , totalChecked )
373
+ footer := m .buildFooter (params . Start , params . CommitSHA , params . LabelFilter , params . ShowDebugInfo , params . AppsChecked , params . TotalChecked )
363
374
sb .WriteString (fmt .Sprintf ("\n \n %s" , footer ))
364
375
365
376
// Only split if content exceeds the max length
366
- if len (sb .String ()) > maxCommentLength {
367
- comments = append (comments , sb .String ()[:maxCommentLength ])
377
+ if len (sb .String ()) > params . MaxCommentLength {
378
+ comments = append (comments , sb .String ()[:params . MaxCommentLength ])
368
379
} else {
369
380
comments = append (comments , sb .String ())
370
381
}
0 commit comments