Skip to content

Commit 21381c7

Browse files
authored
Fix | trim whitespace before adding 🚨 Diff is too long (#249)
1 parent bef1b1b commit 21381c7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pkg/diff/markdown.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ func (m *MarkdownSection) build(maxSize int) (string, bool) {
4040

4141
diffTooLongWarning := "\n🚨 Diff is too long"
4242

43-
spaceForDiffTooLongWarning := spaceForContent - len(diffTooLongWarning)
44-
minNumberOfCharacters := 100
43+
spaceBeforeDiffTooLongWarning := spaceForContent - len(diffTooLongWarning)
4544

46-
if minNumberOfCharacters < spaceForDiffTooLongWarning {
47-
return header + m.comment + content[:spaceForDiffTooLongWarning] + diffTooLongWarning + footer, true
45+
minNumberOfCharacters := 100
46+
if minNumberOfCharacters < spaceBeforeDiffTooLongWarning {
47+
truncatedContent := content[:spaceBeforeDiffTooLongWarning]
48+
truncatedContent = strings.TrimRight(truncatedContent, " \t\n\r")
49+
return header + m.comment + truncatedContent + diffTooLongWarning + footer, true
4850
}
4951

5052
// if there is not enough space for the content, return an empty string

tests/integration-test/branch-9/target-1/output.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ Deleted (9):
436436
- ports:
437437
- - containerPort: 80
438438
- name: http
439-
-
439+
-
440440
🚨 Diff is too long
441441
```
442442

0 commit comments

Comments
 (0)