From 52dfef1a8c3c7d47d5bfda8811e2c6830b42865b Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Thu, 30 May 2024 16:51:30 +0200 Subject: [PATCH] vfmt: exit with error code if encountering diffs with `-diff` flag (#21603) --- cmd/tools/vfmt.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/tools/vfmt.v b/cmd/tools/vfmt.v index f0c9983ebe..efd356e1fb 100644 --- a/cmd/tools/vfmt.v +++ b/cmd/tools/vfmt.v @@ -145,7 +145,9 @@ fn main() { } ecode := if has_internal_error { 5 } else { 0 } if errors > 0 { - eprintln('Encountered a total of: ${errors} formatting errors.') + if !foptions.is_diff { + eprintln('Encountered a total of: ${errors} formatting errors.') + } match true { foptions.is_noerror { exit(0 + ecode) } foptions.is_verify { exit(1 + ecode) } @@ -245,7 +247,7 @@ fn (mut foptions FormatOptions) post_process_file(file string, formatted_file_pa return } println(diff.compare_files(file, formatted_file_path)!) - return + return error('') } if foptions.is_verify { if !is_formatted_different {