Skip to content

Commit 2489fe2

Browse files
egpbosAxel-Naumann
authored andcommitted
pass BASE_COMMIT to format_script.sh
It is not possible to use the base branch name in the GitHub Actions workflow to get the base SHA hash, because the branch name is not known there. To keep the format_script.sh universal, we just pass the SHA hash in from both the Travis and the GH Actions configurations instead.
1 parent a098b3d commit 2489fe2

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.ci/format_script.sh

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -ex
44

5-
BASE_COMMIT=$(git rev-parse $TRAVIS_BRANCH)
65
echo "Running clang-format against branch $TRAVIS_BRANCH, with hash $BASE_COMMIT"
76
COMMIT_FILES=$(git diff --name-only $BASE_COMMIT | grep -i -v LinkDef)
87
RESULT_OUTPUT="$(git-clang-format --commit $BASE_COMMIT --diff --binary `which clang-format` $COMMIT_FILES)"

.github/workflows/code_analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
env:
1313
TRAVIS_BRANCH: ${{ github.base_ref }}
1414
TRAVIS_PULL_REQUEST_BRANCH: ${{ github.head_ref }}
15-
# BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
15+
BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Fetch base_ref HEAD

.travis.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ matrix:
2323
include:
2424
- env: TOOL=clang-format
2525
script: &format_script
26-
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then .ci/format_script.sh; fi
26+
- |
27+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
28+
export BASE_COMMIT=$(git rev-parse $TRAVIS_BRANCH)
29+
.ci/format_script.sh
30+
fi
2731
2832
- env: TOOL=clang-tidy-analyzer
2933
before_script: &copy_headers

0 commit comments

Comments
 (0)