Skip to content

Commit 52dfef1

Browse files
authored
vfmt: exit with error code if encountering diffs with -diff flag (#21603)
1 parent 4bda28b commit 52dfef1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cmd/tools/vfmt.v

+4-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ fn main() {
145145
}
146146
ecode := if has_internal_error { 5 } else { 0 }
147147
if errors > 0 {
148-
eprintln('Encountered a total of: ${errors} formatting errors.')
148+
if !foptions.is_diff {
149+
eprintln('Encountered a total of: ${errors} formatting errors.')
150+
}
149151
match true {
150152
foptions.is_noerror { exit(0 + ecode) }
151153
foptions.is_verify { exit(1 + ecode) }
@@ -245,7 +247,7 @@ fn (mut foptions FormatOptions) post_process_file(file string, formatted_file_pa
245247
return
246248
}
247249
println(diff.compare_files(file, formatted_file_path)!)
248-
return
250+
return error('')
249251
}
250252
if foptions.is_verify {
251253
if !is_formatted_different {

0 commit comments

Comments
 (0)