Skip to content

refactor: extract golden snapshot regeneration + auto-fix in pre-commit#53

Merged
Li-Sanze merged 1 commit into
mainfrom
fix/golden-snapshot-auto-regen
May 31, 2026
Merged

refactor: extract golden snapshot regeneration + auto-fix in pre-commit#53
Li-Sanze merged 1 commit into
mainfrom
fix/golden-snapshot-auto-regen

Conversation

@Li-Sanze
Copy link
Copy Markdown
Collaborator

Problem

release-sync.sh regenerates golden snapshots after version bump, but .githooks/pre-commit only staged 5 managed files — tests/golden-snapshots.json was left unstaged. This caused recurring CI failures on every version bump.

Additionally, the regeneration logic was duplicated: 48 lines of inline Python in release-sync.sh + a separate check in release-preflight.sh.

Changes

  • New: scripts/regenerate-golden-snapshots.py — single source of truth for snapshot regeneration
  • release-preflight.sh: auto-regenerate stale snapshots during pre-commit (instead of just failing)
  • release-sync.sh: replace 48-line inline Python with single script call
  • .githooks/pre-commit: add tests/golden-snapshots.json to staged file list
  • tests/test_release_hooks.py: add new script to test fixture

Net: -50 lines inline Python, +1 reusable script (85 lines with docstrings), deduplication complete.

- New: scripts/regenerate-golden-snapshots.py (single source of truth)
- release-preflight.sh: auto-regenerate stale snapshots during pre-commit
- release-sync.sh: replace 48-line inline Python with script call
- .githooks/pre-commit: stage golden-snapshots.json after version bump
- Graceful ImportError skip for test fixture environments

Context-Checkpoint: B
@Li-Sanze Li-Sanze merged commit 1dd883f into main May 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant