Skip to content

Commit 503ff16

Browse files
vaithakvgvassilev
authored andcommitted
Fix git-clang-format run when PR not on top of master
1 parent 8601757 commit 503ff16

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ jobs:
3838
chmod +x git-clang-format
3939
- name: Run git-clang-format
4040
run: |
41+
PR_BASE=$(git rev-list ${{ github.event.pull_request.head.sha }} ^${{ github.event.pull_request.base.sha }} | tail --lines 1 | xargs -I {} git rev-parse {}~1)
42+
echo "running git clang-format against $PR_BASE commit"
4143
git \
4244
-c color.ui=always \
4345
-c diff.wsErrorHighlight=all \
4446
-c color.diff.whitespace='red reverse' \
45-
clang-format-15 --diff --binary clang-format-15 origin/main -- include/ lib/ || \
47+
clang-format-15 --diff --binary clang-format-15 --commit $PR_BASE -- include/ lib/ || \
4648
(echo "Please run the following git-clang-format locally to fix the formatting: \n
4749
git clang-format origin/main -- include/ lib/" && exit 1)
4850
build:
@@ -381,4 +383,4 @@ jobs:
381383
if: ${{ success() && (matrix.coverage == true) }}
382384
uses: codecov/codecov-action@v3
383385
with:
384-
file: ./coverage.info
386+
file: ./coverage.info

0 commit comments

Comments
 (0)