diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4c05285e6..0194c9393 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,16 +23,12 @@ jobs: - name: Run make indent run: > if [ -z "${{github.base_ref}}" ]; then - make indent + if ! make indent OPTS=--diff; then + exit 1 + fi else git fetch origin ${{github.base_ref}} && - git clang-format --style file --extensions c,h --quiet origin/${{github.base_ref}} - fi && - STATUS=$(git status --porcelain) && - if [ ! -z "$STATUS" ]; then - echo "FAIL: some files are not correctly formatted."; - echo "$STATUS" - git diff - echo "FAIL: please run 'make indent'"; - exit 1; + if ! make indent OPTS=--diff BASE=origin/${{github.base_ref}}; then + exit 1 + fi fi diff --git a/Makefile b/Makefile index 6bb1497b3..83ae7ca5a 100644 --- a/Makefile +++ b/Makefile @@ -461,8 +461,10 @@ fetch-clang-format: .FORCE $(E) ".clang-format" $(Q) scripts/fetch-clang-format.sh +BASE ?= "HEAD~1" +OPTS ?= "--quiet" indent: - find . -name '*.[ch]' -type f -print0 | xargs --null --max-args 128 --max-procs 4 clang-format -i + git clang-format --style file --extensions c,h $(OPTS) $(BASE) .PHONY: indent include Makefile.install