1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:14:58 +00:00

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.
This commit is contained in:
Idan Horowitz 2022-02-19 01:11:11 +02:00
parent 9f85b4ff7b
commit e2d797dd60

View file

@ -43,7 +43,7 @@ ErrorOr<bool> format_file(StringView path, bool inplace)
} else {
out("{}", formatted_gml);
}
return true;
return formatted_gml == contents;
}
ErrorOr<int> serenity_main(Main::Arguments args)
@ -66,14 +66,19 @@ ErrorOr<int> 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;
}