Skip to content

Commit e76ac0e

Browse files
committed
fix the reusable precommit
so it runs on the correct commit sha
1 parent fbd0bf3 commit e76ac0e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

.github/workflows/reusable-pre-commit.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,22 @@ jobs:
6464
java-version: "16"
6565
distribution: "temurin"
6666
cache: "maven"
67+
- name: Determine pre-commit range
68+
id: commit_range
69+
run: |
70+
FROM_REF=$(git merge-base HEAD origin/master)
71+
echo "from_ref=$FROM_REF" >> $GITHUB_OUTPUT
72+
echo "to_ref=HEAD" >> $GITHUB_OUTPUT
73+
echo "Pre-commit will check from $FROM_REF to HEAD"
6774
- id: pre_commit
6875
name: Run pre-commit
6976
if: github.event.action != 'closed' && github.event.pull_request.merged != true
7077
run: |
7178
wget https://github.com/google/google-java-format/releases/download/v1.16.0/google-java-format-1.16.0-all-deps.jar -O google-java-format.jar
7279
pre-commit run --verbose --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure --color=always
7380
env:
74-
FROM_REF: ${{ github.event.pull_request.base.sha }}
75-
TO_REF: ${{ github.event.pull_request.head.sha }}
81+
FROM_REF: ${{ steps.commit_range.outputs.from_ref }}
82+
TO_REF: ${{ steps.commit_range.outputs.to_ref }}
7683
- name: Commit changes
7784
if: failure() && inputs.enable-commit-changes && github.event.pull_request.head.repo.full_name == github.repository
7885
run: |-

0 commit comments

Comments
 (0)