From 9e0e1f29e1408dc6c26068db9bcdac7e1d3eb755 Mon Sep 17 00:00:00 2001 From: Rot127 Date: Tue, 30 Apr 2024 01:41:32 -0500 Subject: [PATCH] Add check if git diff succeeded. --- .github/workflows/clang-tidy.yml | 2 +- run-clang-tidy.sh | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 1a814caee0..95d29cd5a9 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -10,7 +10,7 @@ jobs: analyze: runs-on: ubuntu-latest - name: Install clang-tidy + name: clang-tidy steps: - uses: actions/checkout@v3 - name: Install clang-tidy diff --git a/run-clang-tidy.sh b/run-clang-tidy.sh index 4617884a00..02dab2722f 100755 --- a/run-clang-tidy.sh +++ b/run-clang-tidy.sh @@ -15,7 +15,15 @@ top_level=$(git rev-parse --show-toplevel) echo "\n\n###### REPORT\n\n" -for modified in $(git diff --name-only origin/next); do +git pull origin next +changed_files=$(git diff --name-only origin/next) +if [ $? -ne 0 ]; then + echo "Failed to get changed files." + exit 1 +fi + +for modified in changed_files; do + files_changed=1 full_path="$top_level/$modified" if grep -q "$full_path" $tmp; then echo "$full_path as warnings. Please fix them." @@ -23,8 +31,16 @@ for modified in $(git diff --name-only origin/next); do fi done +if [ -z $files_changed ]; then + echo "No files changed." + exit 0 +fi + if [ -z $needs_fixes ]; then - echo "All good" + echo "None of the changed files has clang-tidy warnings." exit 0 fi + +echo "Some changed files have clang-tidy warnings. Please fix them. Or, if completely unrelated, let us know." + exit 1