mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-28 05:43:50 +00:00
Continue format script when changes detected by clang-format-diff.py (#12329)
Summary: The original [clang-format-diff.py script](https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/clang-format-diff.py), referenced in format.sh, exits with a status of 1 at the end after writing diffs to stderr. Consequently, the format.sh script terminates after initializing the 'diffs' variable. Implemented additional logic in format-diff.sh to ensure continuous execution, even when changes are detected and further formatting is required. Pull Request resolved: https://github.com/facebook/rocksdb/pull/12329 Reviewed By: pdillinger Differential Revision: D53483185 Pulled By: cbi42 fbshipit-source-id: b7adff26f129220941258fd6ee83d053fa12b077
This commit is contained in:
parent
b46f5707c4
commit
daf06f1361
|
@ -137,11 +137,11 @@ then
|
||||||
# should be relevant for formatting fixes.
|
# should be relevant for formatting fixes.
|
||||||
FORMAT_UPSTREAM_MERGE_BASE="$(git merge-base "$FORMAT_UPSTREAM" HEAD)"
|
FORMAT_UPSTREAM_MERGE_BASE="$(git merge-base "$FORMAT_UPSTREAM" HEAD)"
|
||||||
# Get the differences
|
# Get the differences
|
||||||
diffs=$(git diff -U0 "$FORMAT_UPSTREAM_MERGE_BASE" | $CLANG_FORMAT_DIFF -p 1)
|
diffs=$(git diff -U0 "$FORMAT_UPSTREAM_MERGE_BASE" | $CLANG_FORMAT_DIFF -p 1) || true
|
||||||
echo "Checking format of changes not yet in $FORMAT_UPSTREAM..."
|
echo "Checking format of changes not yet in $FORMAT_UPSTREAM..."
|
||||||
else
|
else
|
||||||
# Check the format of uncommitted lines,
|
# Check the format of uncommitted lines,
|
||||||
diffs=$(git diff -U0 HEAD | $CLANG_FORMAT_DIFF -p 1)
|
diffs=$(git diff -U0 HEAD | $CLANG_FORMAT_DIFF -p 1) || true
|
||||||
echo "Checking format of uncommitted changes..."
|
echo "Checking format of uncommitted changes..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -149,6 +149,9 @@ if [ -z "$diffs" ]
|
||||||
then
|
then
|
||||||
echo "Nothing needs to be reformatted!"
|
echo "Nothing needs to be reformatted!"
|
||||||
exit 0
|
exit 0
|
||||||
|
elif [ $? -ne 1 ]; then
|
||||||
|
# CLANG_FORMAT_DIFF will exit on 1 while there is suggested changes.
|
||||||
|
exit $?
|
||||||
elif [ $CHECK_ONLY ]
|
elif [ $CHECK_ONLY ]
|
||||||
then
|
then
|
||||||
echo "Your change has unformatted code. Please run make format!"
|
echo "Your change has unformatted code. Please run make format!"
|
||||||
|
|
Loading…
Reference in a new issue