Skip to content

Commit

Permalink
Change exit code of clang-format (#192)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yjaeseok authored and romandev committed Nov 22, 2017
1 parent d5b6578 commit 57bd300
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
18 changes: 1 addition & 17 deletions bootstrap/command/lint
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions third_party/clang-format/git-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 57bd300

Please sign in to comment.