update clang-format checks for full history (#3395)
* update clang-format checks for full history checks for clang-format 10.0.0 * no need to explicitly install as clang-format, installed versions suffice
This commit is contained in:
parent
4196e7364b
commit
18640c19dd
3 changed files with 50 additions and 22 deletions
4
.github/workflows/analyzers.yml
vendored
4
.github/workflows/analyzers.yml
vendored
|
|
@ -12,10 +12,6 @@ jobs:
|
||||||
env:
|
env:
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
run: sudo apt-get install clang-format-10
|
run: sudo apt-get install clang-format-10
|
||||||
- name: Setting clang-format 10 as the default
|
|
||||||
env:
|
|
||||||
DEBIAN_FRONTEND: noninteractive
|
|
||||||
run: sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-10 1000
|
|
||||||
- name: Clang Format
|
- name: Clang Format
|
||||||
run: ci/check-commit-format.sh
|
run: ci/check-commit-format.sh
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,44 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
FOUND=0
|
||||||
|
|
||||||
|
# hard requirement of clang-format 10.0.0
|
||||||
|
CF_EXECUTABLE='
|
||||||
|
clang-format-10.0.0
|
||||||
|
clang-format-10.0
|
||||||
|
clang-format-10
|
||||||
|
clang-format
|
||||||
|
'
|
||||||
|
|
||||||
|
# check different executable strings
|
||||||
|
for executable in $CF_EXECUTABLE; do
|
||||||
|
if type -p "$executable" >/dev/null; then
|
||||||
|
clang_format="$executable"
|
||||||
|
FOUND=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# alert if not installed
|
||||||
|
if [ $FOUND == 0 ]; then
|
||||||
|
echo "clang-format not found, please install 10.0.0 first"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if old version is found
|
||||||
|
if ! "$clang_format" --version | grep '10.0.0' &>/dev/null; then
|
||||||
|
echo "clang-format version 10.0.0 is required, please update it"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||||
|
|
||||||
"${REPO_ROOT}/ci/update-clang-format"
|
"${REPO_ROOT}/ci/update-clang-format"
|
||||||
|
|
||||||
RESULT=$(python $REPO_ROOT/ci/git-clang-format.py --diff -f --commit HEAD~1 --extensions "hpp,cpp")
|
RESULT=$(python $REPO_ROOT/ci/git-clang-format.py --diff --extensions "hpp,cpp")
|
||||||
if [ "$RESULT" != "no modified files to format" ] && [ "$RESULT" != "clang-format did not modify any files" ]; then
|
if [ "$RESULT" != "no modified files to format" ] && [ "$RESULT" != "clang-format did not modify any files" ]; then
|
||||||
python $REPO_ROOT/ci/git-clang-format.py --diff -f --commit HEAD~1 --extensions "hpp,cpp"
|
python $REPO_ROOT/ci/git-clang-format.py --diff --extensions "hpp,cpp"
|
||||||
echo
|
echo
|
||||||
echo "Code formatting differs from expected - please run ci/clang-format-all.sh"
|
echo "Code formatting differs from expected - please run ci/clang-format-all.sh"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue