From 57bd3004e26f35f7b831a0ada893cab7875f3b31 Mon Sep 17 00:00:00 2001 From: Jake Yoon Date: Thu, 23 Nov 2017 00:05:45 +0900 Subject: [PATCH] Change exit code of clang-format (#192) Because clang-format always returns an exit code of 0, We must check the output of the clang-format as a law string and re-returns exit code 0 or 1. So I would like to change clang-format exit code. - There is no need to change format (exit 0). - There is need to change format (exit 1). Finally, I want to contribute this to the upstream. ISSUE=#191 --- bootstrap/command/lint | 18 +----------------- third_party/clang-format/git-clang-format | 3 +++ 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/bootstrap/command/lint b/bootstrap/command/lint index 19689a4..d8b74fe 100755 --- a/bootstrap/command/lint +++ b/bootstrap/command/lint @@ -16,20 +16,4 @@ . $BACARDI_PATH/bootstrap/common/path_info.sh -format_diff="$(bootstrap_command_path)/format --diff" - -function need_to_format() { - result=$($format_diff) - if [ "$result" = "no modified files to format" ] \ - || [ "$result" = "clang-format did not modify any files" ]; then - return 1 - else - $format_diff - return 0 - fi -} - -if need_to_format; then - echo "lint error: You can fix the lint error with |bacardi format| command." - exit 1 -fi +$(bootstrap_command_path)/format --diff diff --git a/third_party/clang-format/git-clang-format b/third_party/clang-format/git-clang-format index 60cd4fb..7d88c04 100755 --- a/third_party/clang-format/git-clang-format +++ b/third_party/clang-format/git-clang-format @@ -171,6 +171,9 @@ def main(): print('clang-format did not modify any files') elif opts.diff: print_diff(old_tree, new_tree) + # FIXME(yjaeseok): change exit code of clang-format. + # If there is a difference with clang-format we should return failure. + sys.exit(1) else: changed_files = apply_changes(old_tree, new_tree, force=opts.force, patch_mode=opts.patch)