Skip to content

Commit

Permalink
Check the code format before commit (vesoft-inc#17)
Browse files Browse the repository at this point in the history
* Check the code format before commit.

* Only check the staged content.

Co-authored-by: Shylock Hg <[email protected]>
  • Loading branch information
nebula-bots and Shylock-Hg authored Sep 2, 2021
1 parent 2cacdae commit 1479413
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions .linters/cpp/hooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@ python3 $CPPLINT --quiet --extensions=$CPPLINT_EXTENS \
--filter=$CPPLINT_FILTER --linelength=100 $CHECK_FILES 2>&1

result=$?
if [ $result -eq 0 ]
then
exit 0
else
if [ ! $result -eq 0 ]; then
echo "cpplint code style check failed, please fix and recommit."
exit 1
fi

echo "Performing C++ code format check..."

CLANG_HOME=/opt/vesoft/toolset/clang/10.0.0/
res=$(git diff -U0 --no-color --staged | $CLANG_HOME/share/clang/clang-format-diff.py -p1 -binary $CLANG_HOME/bin/clang-format)
if [[ ! -z $res ]]; then
echo "The code format is not well..."
echo $res
exit 1
fi

0 comments on commit 1479413

Please sign in to comment.