From 5c0c7a6f213609f5be8258f07b763201ad182876 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 28 May 2026 09:16:39 -0500 Subject: fix(sync-check): ignore generated python and elisp artifacts Pre-commit caught a false-positive on its first real-world run. The .ai/scripts/__pycache__ directory created by make test (pytest writes .pyc and .pytest_cache, emacs writes .elc) was flagged as drift against the canonical's clean tree. Added matching --exclude patterns to the diff -rq check and the --fix rsync calls. Patterns: __pycache__, *.pyc, *.pyo, .pytest_cache, *.elc. The --fix excludes prevent rsync's --delete from wiping the mirror's __pycache__ when the canonical has none. Four new bats tests cover the exclusions. All 12 pass. --- scripts/tests/sync-check.bats | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'scripts/tests') diff --git a/scripts/tests/sync-check.bats b/scripts/tests/sync-check.bats index df775b3..17c9189 100644 --- a/scripts/tests/sync-check.bats +++ b/scripts/tests/sync-check.bats @@ -84,3 +84,33 @@ setup() { [ "$status" -eq 2 ] [[ "$output" == *"not inside a git checkout"* ]] } + +@test "generated Python artifacts in mirror don't count as drift" { + mkdir -p .ai/scripts/__pycache__ + touch .ai/scripts/__pycache__/foo.cpython-314.pyc + touch .ai/scripts/some.pyc + run scripts/sync-check.sh + [ "$status" -eq 0 ] +} + +@test "compiled elisp artifacts in mirror don't count as drift" { + touch .ai/scripts/foo.elc + run scripts/sync-check.sh + [ "$status" -eq 0 ] +} + +@test "pytest cache in mirror doesn't count as drift" { + mkdir -p .ai/scripts/.pytest_cache + touch .ai/scripts/.pytest_cache/CACHEDIR.TAG + run scripts/sync-check.sh + [ "$status" -eq 0 ] +} + +@test "--fix preserves generated artifacts in mirror" { + mkdir -p .ai/scripts/__pycache__ + touch .ai/scripts/__pycache__/foo.cpython-314.pyc + echo "drift" > .ai/protocols.org + run scripts/sync-check.sh --fix + [ "$status" -eq 0 ] + [ -f .ai/scripts/__pycache__/foo.cpython-314.pyc ] +} -- cgit v1.2.3