Skip to content

Commit 39aefb6

Browse files
committed
fix: diff enforces one line per file
This allows for whitespaces in file names and is a much cleaner approach.
1 parent a7bc38f commit 39aefb6

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

pipeline.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,16 @@ func diff(command string) ([]string, error) {
106106
}
107107

108108
trimmed := strings.TrimSpace(output)
109+
if trimmed == "" {
110+
return nil, nil
111+
}
109112

110-
// Git diff --name-only outputs one file per line. Split on newlines to
111-
// preserve filenames that contain spaces. Fall back to strings.Fields
112-
// for single-line output (e.g. legacy diff commands) for backward compat.
113113
var fields []string
114-
if strings.Contains(trimmed, "\n") {
115-
for _, line := range strings.Split(trimmed, "\n") {
116-
line = strings.TrimSpace(line)
117-
if line != "" {
118-
fields = append(fields, line)
119-
}
114+
for _, line := range strings.Split(trimmed, "\n") {
115+
line = strings.TrimSpace(line)
116+
if line != "" {
117+
fields = append(fields, line)
120118
}
121-
} else {
122-
fields = strings.Fields(trimmed)
123119
}
124120

125121
paths := make([]string, 0, len(fields))

0 commit comments

Comments
 (0)