Minor changes to clang-format workflow (#1177)
This commit is contained in:
parent
de62620de1
commit
a1385cb481
3
.github/workflows/format.yml
vendored
3
.github/workflows/format.yml
vendored
|
@ -7,6 +7,7 @@ on:
|
||||||
- '**.cpp'
|
- '**.cpp'
|
||||||
- '**.h'
|
- '**.h'
|
||||||
- '!src/libs/**'
|
- '!src/libs/**'
|
||||||
|
- '!src/FreeRTOS/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-format:
|
test-format:
|
||||||
|
@ -18,8 +19,6 @@ jobs:
|
||||||
|
|
||||||
- name: Configure git
|
- name: Configure git
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "-"
|
|
||||||
git config --global user.name "Autoformatter"
|
|
||||||
git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" --depth=1000
|
git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" --depth=1000
|
||||||
|
|
||||||
- name: Install clang-format
|
- name: Install clang-format
|
||||||
|
|
|
@ -16,18 +16,17 @@ for file in $CHANGED_FILES
|
||||||
do
|
do
|
||||||
[ -e "$file" ] || continue
|
[ -e "$file" ] || continue
|
||||||
case "$file" in
|
case "$file" in
|
||||||
src/libs/*) continue ;;
|
src/libs/*|src/FreeRTOS/*) continue ;;
|
||||||
*.cpp|*.h)
|
*.cpp|*.h)
|
||||||
echo Checking "$file"
|
echo Checking "$file"
|
||||||
clang-format -i "$file"
|
PATCH="$(basename "$file").patch"
|
||||||
if ! git diff --quiet
|
git clang-format-12 -q --style file --diff "$GITHUB_BASE_REF" "$file" > "$PATCH"
|
||||||
|
if [ -s "$PATCH" ]
|
||||||
then
|
then
|
||||||
printf "\033[31mError:\033[0m Formatting error in %s\n" "$file"
|
printf "\033[31mError:\033[0m Formatting error in %s\n" "$file"
|
||||||
CHANGED=1
|
CHANGED=1
|
||||||
git add "$file"
|
else
|
||||||
git commit -q -m "Apply clang-format to $(basename "$file")"
|
rm "$PATCH"
|
||||||
printf "Creating patch "
|
|
||||||
git format-patch HEAD~
|
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue