Skip to content

Commit afff49b

Browse files
authored
[CI] Fix obtaining the diff for the pull request (#1197)
New commands will fetch 3 commits: merge commit and two parent commits with the state of the target branch and PR branch. Signed-off-by: Alexey Bader <[email protected]>
1 parent 6ae1cfe commit afff49b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

.github/workflows/clang-format.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v2
1313
with:
14-
# checkout PR head
15-
ref: '${{github.event.pull_request.head.sha}}'
16-
- name: Fetch target branch
17-
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/${{github.base_ref}}:refs/remotes/origin/${{github.base_ref}}
14+
fetch-depth: 2
1815

1916
- name: Get clang-format first
2017
run: sudo apt-get install -yqq clang-format-9
2118

2219
- name: Run clang-format for the patch
2320
run: |
24-
git diff -U0 --no-color origin/${{github.base_ref}}...HEAD | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch
21+
git diff -U0 --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} -- | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch
2522
2623
# Add patch with formatting fixes to CI job artifacts
2724
- uses: actions/upload-artifact@v1

0 commit comments

Comments
 (0)