From b98822c17af0cd3ce86003355ced316c5f78acbe Mon Sep 17 00:00:00 2001 From: Michael Muller Date: Fri, 25 Mar 2022 12:50:27 -0400 Subject: [PATCH] Terminate with exit code of 1 on format check fail (#1570) The format check script currently outputs "true" if there were files that need reformatting and "false" if not, which is useful for gradle but less so for other applications (notably commit hooks). Terminate with an exit code of 1 if the format check fails. TESTED: Tried this from both a pre-commit hook and from the gradle build. --- java-format/google-java-format-git-diff.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java-format/google-java-format-git-diff.sh b/java-format/google-java-format-git-diff.sh index d5d861db8..851b0bf84 100755 --- a/java-format/google-java-format-git-diff.sh +++ b/java-format/google-java-format-git-diff.sh @@ -139,10 +139,11 @@ function isJavaFormatNeededOnDiffs() { if [[ ${modifiedLineCount} -ne 0 ]]; then echo "true" + exit 1 else echo "false" + exit 0 fi - exit 0 } # The main function of this script: