Skip to content

Commit d771aad

Browse files
fix(governance): use git ls-files instead of find for banned-language checks (#248)
## Summary - The nine `find`-based file list variables in the `Check banned-language files` step are replaced with equivalent `git ls-files` glob patterns - `git ls-files` only returns tracked files, which by definition respects `.gitignore` — vendored dirs like `deps/`, `node_modules/`, `_build/` cannot produce false-positives - Existing `.hypatia-baseline.json` and `.hypatia-ignore` exemption mechanisms are unchanged - Root cause: `developer-ecosystem@baab1534` — governance false-positives from gitignored vendor directories ## Test plan - [ ] CI run on a repo with `node_modules/` in `.gitignore` — no false-positive `*.res` or `*.js` findings from vendored deps - [ ] CI run on a clean repo — all nine banned-extension checks pass as before - [ ] `git ls-files` works correctly on fresh PR checkouts (actions/checkout populates the index first) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7732aec commit d771aad

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

.github/workflows/governance-reusable.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,26 +290,30 @@ jobs:
290290
echo "✅ No non-exempt ${label}"
291291
}
292292
293-
RES_FILES=$(find . -name "*.res" -not -path "./node_modules/*" -not -path "./.git/*" || true)
294-
GO_FILES=$(find . -name "*.go" -not -path "./.git/*" || true)
295-
PY_FILES=$(find . -name "*.py" -not -path "./.git/*" \
293+
# Use `git ls-files` instead of `find` so only TRACKED files are
294+
# inspected. This respects .gitignore by definition — vendored
295+
# deps in deps/, node_modules/, _build/ etc. are never tracked
296+
# and cannot produce false-positives. Root cause for the switch:
297+
# developer-ecosystem@baab1534 had false-positive governance
298+
# failures because `find` crawled gitignored vendor directories.
299+
# `git ls-files` works correctly on fresh PR checkouts because
300+
# actions/checkout populates the index before running workflows.
301+
RES_FILES=$(git ls-files '*.res' || true)
302+
GO_FILES=$(git ls-files '*.go' || true)
303+
PY_FILES=$(git ls-files '*.py' \
296304
| grep -v salt | grep -v _states \
297305
| grep -v _modules | grep -v pillar | grep -v venv \
298306
| grep -v __pycache__ || true)
299-
MAKE_FILES=$(find . \( -name "Makefile" -o -name "Makefile.*" -o -name "*.mk" \) \
300-
-not -path "./.git/*" -not -path "./.github/*" || true)
301-
JAVA_FILES=$(find . \( -name "*.java" -o -name "*.kt" -o -name "*.kts" \) \
302-
-not -path "./.git/*" || true)
303-
SWIFT_FILES=$(find . -name "*.swift" -not -path "./.git/*" || true)
304-
DART_FILES=$(find . \( -name "*.dart" -o -name "pubspec.yaml" \) \
305-
-not -path "./.git/*" || true)
307+
MAKE_FILES=$(git ls-files 'Makefile' 'Makefile.*' '*.mk' \
308+
| grep -v '\.github/' || true)
309+
JAVA_FILES=$(git ls-files '*.java' '*.kt' '*.kts' || true)
310+
SWIFT_FILES=$(git ls-files '*.swift' || true)
311+
DART_FILES=$(git ls-files '*.dart' 'pubspec.yaml' || true)
306312
# V-lang detected by manifest (v.mod / vpkg.json); the .v extension
307313
# collides with Verilog so we never key on it.
308-
VMOD_FILES=$(find . \( -name "v.mod" -o -name "vpkg.json" \) \
309-
-not -path "./node_modules/*" -not -path "./.git/*" || true)
314+
VMOD_FILES=$(git ls-files 'v.mod' 'vpkg.json' || true)
310315
# ATS2 source extensions: rejected in favour of Idris2 / Rust/SPARK.
311-
ATS2_FILES=$(find . \( -name "*.dats" -o -name "*.sats" -o -name "*.hats" \) \
312-
-not -path "./.git/*" || true)
316+
ATS2_FILES=$(git ls-files '*.dats' '*.sats' '*.hats' || true)
313317
314318
enforce "ReScript files" "use AffineScript instead" "$RES_FILES"
315319
enforce "Go files" "use Rust/WASM instead" "$GO_FILES"

0 commit comments

Comments
 (0)