From c8392991ec4a38ac48973d5bd63d4299d59dd9b3 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Mon, 24 Aug 2026 22:10:46 -0700 Subject: [PATCH] fix(ci): run prek over all files when a push has no base commit --- .github/workflows/prek-check.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/prek-check.yml b/.github/workflows/prek-check.yml index 41454bd16..267f21c55 100644 --- a/.github/workflows/prek-check.yml +++ b/.github/workflows/prek-check.yml @@ -49,4 +49,16 @@ jobs: - name: Run prek checks (push) if: github.event_name == 'push' - run: prek run --from-ref ${{ github.event.before }} --to-ref ${{ github.event.after }} --show-diff-on-failure + env: + BEFORE: ${{ github.event.before }} + AFTER: ${{ github.event.after }} + run: | + # A push that creates a branch reports an all-zero "before", and a + # force-push can name one this clone no longer has. Neither is a commit, + # so the range would be invalid; check every file instead. + if git rev-parse --verify --quiet "$BEFORE^{commit}" >/dev/null; then + prek run --from-ref "$BEFORE" --to-ref "$AFTER" --show-diff-on-failure + else + echo "no usable base commit ($BEFORE); checking all files" + prek run --all-files --show-diff-on-failure + fi