File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,24 @@ jobs:
3030 # the pre-commit.yaml workflow does not immediately fail on the later
3131 # Fetch commit refs.
3232 first="0000000000000000000000000000000000000000"
33+ event_before="${{ github.event.before }}"
34+ base_ref="${{ github.base_ref }}"
35+
36+ if [[ -z "$base_ref" ]]; then
37+ first_base_ref=""
38+ else
39+ first_base_ref="$(git rev-parse origin/$base_ref)"
40+ fi
3341
3442 if [[ ${{ github.event_name }} == 'push' ]]; then
35- if [[ ${{ github.event.before }} == $first ]]; then
43+ if [[ $event_before == $first ]]; then
3644 echo "This is the first commit in the repository. No commits to check."
3745 echo "skip_pre-commit=true" >> $GITHUB_OUTPUT
3846 else
3947 echo "skip_pre-commit=false" >> $GITHUB_OUTPUT
4048 fi
4149 elif [[ ${{ github.event_name }} == 'pull_request' ]]; then
42- if [[ $(git rev-parse origin/${{ github.base_ref }}) == $first ]];then
50+ if [[ $first_base_ref == $first ]];then
4351 echo "This is the first commit in the repository. No commits to check."
4452 echo "skip_pre-commit=true" >> $GITHUB_OUTPUT
4553 else
You can’t perform that action at this time.
0 commit comments