diff options
Diffstat (limited to 'scripts/sync-check.sh')
| -rwxr-xr-x | scripts/sync-check.sh | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/scripts/sync-check.sh b/scripts/sync-check.sh index 8fb9ab0..cc7bc62 100755 --- a/scripts/sync-check.sh +++ b/scripts/sync-check.sh @@ -35,12 +35,23 @@ fi paths=(protocols.org workflows scripts) +# Generated artifacts that should never count as drift. These appear on the +# mirror side when tests run (pytest writes .pyc and .pytest_cache; emacs +# writes .elc) but aren't part of the canonical source. +exclude_args=( + --exclude='__pycache__' + --exclude='*.pyc' + --exclude='*.pyo' + --exclude='.pytest_cache' + --exclude='*.elc' +) + check_drift() { local drift=0 for relpath in "${paths[@]}"; do - if ! diff -rq "$canonical/$relpath" "$mirror/$relpath" >/dev/null 2>&1; then + if ! diff -rq "${exclude_args[@]}" "$canonical/$relpath" "$mirror/$relpath" >/dev/null 2>&1; then echo "drift: claude-templates/.ai/$relpath ↔ .ai/$relpath" >&2 - diff -rq "$canonical/$relpath" "$mirror/$relpath" 2>&1 | head -20 >&2 + diff -rq "${exclude_args[@]}" "$canonical/$relpath" "$mirror/$relpath" 2>&1 | head -20 >&2 drift=1 fi done @@ -54,9 +65,18 @@ fi if [ "${1:-}" = "--fix" ]; then echo "" >&2 echo "sync-check --fix: syncing canonical → mirror..." >&2 + # Same exclude patterns as the diff so generated files in the mirror + # aren't wiped by --delete when canonical has no counterpart. + rsync_excludes=( + --exclude='__pycache__' + --exclude='*.pyc' + --exclude='*.pyo' + --exclude='.pytest_cache' + --exclude='*.elc' + ) rsync -a "$canonical/protocols.org" "$mirror/protocols.org" - rsync -a --delete "$canonical/workflows/" "$mirror/workflows/" - rsync -a --delete "$canonical/scripts/" "$mirror/scripts/" + rsync -a --delete "${rsync_excludes[@]}" "$canonical/workflows/" "$mirror/workflows/" + rsync -a --delete "${rsync_excludes[@]}" "$canonical/scripts/" "$mirror/scripts/" if check_drift; then echo "sync-check --fix: resolved." >&2 echo "Re-stage the synced files and retry the commit." >&2 |
