diff --git a/.gitea/workflows/quality.yaml b/.gitea/workflows/quality.yaml index 30c4b01..e67dae8 100644 --- a/.gitea/workflows/quality.yaml +++ b/.gitea/workflows/quality.yaml @@ -38,14 +38,11 @@ jobs: api: ${{ steps.detect.outputs.api }} docker: ${{ steps.detect.outputs.docker }} steps: - - if: ${{ inputs.is_pull_request }} - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: + # Push may contain several commits; github.event.before is then + # more than one parent away. fetch-depth: 2 only has HEAD~1. fetch-depth: 0 - - if: ${{ inputs.is_pull_request == false }} - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 2 - id: detect name: Detect changed paths per module env: @@ -72,12 +69,16 @@ jobs: done } + has_commit() { + git cat-file -e "${1}^{commit}" 2>/dev/null + } + if [ "$IS_PR" = "true" ]; then FILES="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")" else after="${HEAD_SHA:-$(git rev-parse HEAD)}" before="$BEFORE_SHA" - if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" ]; then + if [ -n "$before" ] && [ "$before" != "0000000000000000000000000000000000000000" ] && has_commit "$before"; then FILES="$(git diff --name-only "$before" "$after")" elif git rev-parse --verify HEAD~1 >/dev/null 2>&1; then FILES="$(git diff --name-only HEAD~1 HEAD)"