diff --git a/.github/workflows/pr-format-check.yml b/.github/workflows/pr-format-check.yml index 5d448de09..26203ab3b 100644 --- a/.github/workflows/pr-format-check.yml +++ b/.github/workflows/pr-format-check.yml @@ -1,5 +1,3 @@ -name: Clang Format Check - on: pull_request: branches: @@ -13,14 +11,23 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up clang-format run: sudo apt-get install clang-format + - name: Fetch main branch + run: git fetch origin main:main + + - name: Get commit ID of main branch + run: | + MAIN_COMMIT=$(git rev-parse origin/main) + echo "Commit ID of main branch: $MAIN_COMMIT" + - name: Check code formatting run: | - git clang-format --style=firmware/.clang-format --diff HEAD -- '*.cpp' '*.h' - + git clang-format --style=firmware/.clang-format --diff $MAIN_COMMIT..HEAD '*.cpp' '*.h' - name: Check for changes id: check_changes