Skip to content

Commit 05ebff6

Browse files
fwieselmumoshu
authored andcommitted
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 de536b3 commit 05ebff6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

diff/diff.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ func printDiffRecord(diff difflib.DiffRecord, to io.Writer) {
210210
case difflib.LeftOnly:
211211
fmt.Fprintf(to, "%s\n", ansi.Color("- "+text, "red"))
212212
case difflib.Common:
213-
fmt.Fprintf(to, "%s\n", " "+text)
213+
if text == "" {
214+
fmt.Fprintln(to)
215+
} else {
216+
fmt.Fprintf(to, "%s\n", " "+text)
217+
}
214218
}
215219
}
216220

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)