From e2d797dd607b5cd748a0cf7067cf9edd4efa93cc Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 19 Feb 2022 01:11:11 +0200 Subject: [PATCH] gml-format: Exit with non-0 exit code when the file formatting changes This let's CI detect when the changes include incorrect GML formatting. We now also print a message to make it obvious why CI failed. --- Userland/Utilities/gml-format.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp index 84d014bff8..f278f290a1 100644 --- a/Userland/Utilities/gml-format.cpp +++ b/Userland/Utilities/gml-format.cpp @@ -43,7 +43,7 @@ ErrorOr format_file(StringView path, bool inplace) } else { out("{}", formatted_gml); } - return true; + return formatted_gml == contents; } ErrorOr serenity_main(Main::Arguments args) @@ -66,14 +66,19 @@ ErrorOr serenity_main(Main::Arguments args) TRY(Core::System::pledge("stdio rpath", nullptr)); #endif - unsigned exit_code = 0; - if (files.is_empty()) files.append("-"); + + auto formatting_changed = false; for (auto& file : files) { if (!TRY(format_file(file, inplace))) - exit_code = 1; + formatting_changed = true; } - return exit_code; + if (formatting_changed) { + dbgln("Some GML formatting issues were encountered."); + return 1; + } + + return 0; }