Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/diff/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ func (m *MarkdownOutput) printDiff(maxDiffMessageCharCount uint) string {
}

if sectionsDiff.Len() == 0 {
sectionsDiff.WriteString("No changes found")
if len(m.sections) > 0 {
sectionsDiff.WriteString(fmt.Sprintf("⚠️ Changes were found but `--max-diff-length` (%d) is too small to display them. Increase the value or check the HTML output instead.", maxDiffMessageCharCount))
log.Warn().Msgf("🚨 --max-diff-length (%d) is too small to display any diff content. Increase the value or use the HTML output instead.", maxDiffMessageCharCount)
} else {
sectionsDiff.WriteString("No changes found")
}
}

output = strings.ReplaceAll(output, "%info_box%", m.statsInfo.String())
Expand Down
29 changes: 29 additions & 0 deletions pkg/diff/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,35 @@ func TestMarkdownOutput_PrintDiff(t *testing.T) {
"⚠️⚠️⚠️ Diff exceeds max length",
},
},
{
name: "Extremely small max-diff-length shows helpful message instead of no changes found",
output: MarkdownOutput{
title: "Tiny Diff",
summary: "Some changes",
sections: []MarkdownSection{
{
appName: "My App",
filePath: "path/to/app.yaml",
appURL: "",
resources: []ResourceSection{
{Header: "@@ Application modified: My App @@", Content: "+ new line\n- old line\n"},
},
},
},
statsInfo: StatsInfo{
ApplicationCount: 1,
},
},
maxSize: 3, // Extremely small - like the user in issue #392
maxDiffMessageCharCount: 3,
expectedContains: []string{
"too small to display them",
"--max-diff-length",
},
expectedNotContains: []string{
"No changes found",
},
},
{
name: "Truncated output shows warning",
output: MarkdownOutput{
Expand Down
Loading