Skip to content

Commit f7d8a09

Browse files
committed
Do not indent blank lines
The test case contains blank lines with white-spaces and many editors do trim those, so we adopt the test as well as the code to not indent blank lines
1 parent 97f7749 commit f7d8a09

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

diff/diff.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func Releases(oldIndex, newIndex map[string]*manifest.MappingResult, suppressedK
148148
return Manifests(oldIndex, newIndex, suppressedKinds, showSecrets, context, output, stripTrailingCR, to)
149149
}
150150

151-
func diffMappingResults(oldContent *manifest.MappingResult, newContent *manifest.MappingResult, stripTrailingCR bool ) []difflib.DiffRecord {
151+
func diffMappingResults(oldContent *manifest.MappingResult, newContent *manifest.MappingResult, stripTrailingCR bool) []difflib.DiffRecord {
152152
return diffStrings(oldContent.Content, newContent.Content, stripTrailingCR)
153153
}
154154

@@ -209,7 +209,11 @@ func printDiffRecord(diff difflib.DiffRecord, to io.Writer) {
209209
case difflib.LeftOnly:
210210
fmt.Fprintf(to, "%s\n", ansi.Color("- "+text, "red"))
211211
case difflib.Common:
212-
fmt.Fprintf(to, "%s\n", " "+text)
212+
if text == "" {
213+
fmt.Fprintln(to)
214+
} else {
215+
fmt.Fprintf(to, "%s\n", " "+text)
216+
}
213217
}
214218
}
215219

diff/diff_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ metadata:
204204
}
205205

206206
require.Equal(t, `default, nginx, Deployment (apps) has changed:
207-
207+
208208
- apiVersion: apps/v1beta1
209209
+ apiVersion: apps/v1
210210
kind: Deployment
211211
metadata:
212212
name: nginx
213-
213+
214214
`, buf1.String())
215215
})
216216

0 commit comments

Comments
 (0)