Skip to content

Commit 61d0732

Browse files
committed
fix edge case
Signed-off-by: Mmadu Manasseh <manasseh.mmadu@zapier.com>
1 parent 2daf8b9 commit 61d0732

File tree

3 files changed

+429
-6
lines changed

3 files changed

+429
-6
lines changed

pkg/msg/message.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (m *Message) BuildComment(
237237
}
238238

239239
updateWritten := false
240-
for _, appName := range names {
240+
for appIndex, appName := range names {
241241
if m.isDeleted(appName) {
242242
continue
243243
}
@@ -329,8 +329,8 @@ func (m *Message) BuildComment(
329329
comments = append(comments, sb.String())
330330
sb.Reset()
331331
sb.WriteString(header)
332-
sb.WriteString(appHeader)
333332
contentLength = len(continuedHeader)
333+
sb.WriteString(appHeader)
334334
contentLength += len(appHeader)
335335
msg = secondPart
336336
} else {
@@ -341,9 +341,16 @@ func (m *Message) BuildComment(
341341
}
342342
}
343343

344-
// Close the app details block
345-
sb.WriteString("\n</details>\n")
346-
contentLength += len("\n</details>\n")
344+
// Don't write if there's no more apps to write. An unclosed details tag wouldn't cause an issue
345+
// unless there's more contents to write
346+
if appIndex < len(names)-1 {
347+
closingDetailsTag := "\n</details>\n"
348+
if contentLength+len(closingDetailsTag) > maxContentLength {
349+
appendChunk(appHeader)
350+
} // Close the app details block
351+
sb.WriteString(closingDetailsTag)
352+
contentLength += len(closingDetailsTag)
353+
}
347354

348355
updateWritten = true
349356
}

0 commit comments

Comments
 (0)