From a95f7c1d18e2d3d1a8d3f42981b6f88b22cbb0d1 Mon Sep 17 00:00:00 2001 From: Elijah Date: Fri, 7 Aug 2026 19:50:38 -0700 Subject: [PATCH] Harden changed-file lint workflow --- .forgejo/workflows/build.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 7abe151..3be9b0c 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -11,6 +11,9 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v4 + with: + # The changed-file lint step compares the pushed commit with its parent. + fetch-depth: 2 - name: Log into Local Registry run: | @@ -33,8 +36,13 @@ jobs: - name: Lint changed source files run: | - FILES=$(git diff --name-only HEAD^ HEAD -- '*.ts' '*.tsx' '*.js' '*.mjs') - if [ -n "$FILES" ]; then npx eslint $FILES; fi + if BASE=$(git rev-parse HEAD^ 2>/dev/null); then + git diff --name-only -z "$BASE" HEAD -- '*.ts' '*.tsx' '*.js' '*.mjs' | + xargs -0 -r npx eslint + else + git ls-files -z -- '*.ts' '*.tsx' '*.js' '*.mjs' | + xargs -0 -r npx eslint + fi - name: Build and smoke production image run: |