mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 11:55:51 +00:00
Fix pre-commit to only check staged files
This commit is contained in:
committed by
Michael Legleux
parent
a47bf2e8fe
commit
b13c44eb12
@@ -2,14 +2,16 @@
|
||||
|
||||
exec 1>&2
|
||||
|
||||
# format all relevant sources
|
||||
find src unittests -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format -i
|
||||
# paths to check and re-format
|
||||
sources="src unittests"
|
||||
formatter="clang-format -i"
|
||||
|
||||
# check how many lines differ
|
||||
lines=$(git diff src unittests | wc -l)
|
||||
first=$(git diff $sources)
|
||||
find $sources -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 $formatter
|
||||
second=$(git diff $sources)
|
||||
changes=$(diff <(echo "$first") <(echo "$second") | wc -l)
|
||||
|
||||
# check if there is any updated files
|
||||
if [ "$lines" != "0" ]; then
|
||||
if [ "$changes" != "0" ]; then
|
||||
cat <<\EOF
|
||||
|
||||
WARNING
|
||||
|
||||
Reference in New Issue
Block a user