Files
crewli/lefthook.yml
bert.hausmans 1b06804e8c fix(lefthook): serialize pre-push commands to avoid stdin deadlock
Default parallel execution of sync-check and git-lfs commands within
the pre-push hook deadlocks: both read from stdin (git pipes the push
refspec to pre-push hooks), and two parallel readers never reach EOF.

Add piped: true to force sequential execution. sync-check runs first
(only inspects push_files via lefthook templating, doesn't actually
consume stdin), then git-lfs runs second with clean stdin access.

Observed during chore/test-infra-001 sprint: LFS upload completed
100% but pre-push hook hung indefinitely. Workaround was --no-verify;
this commit removes the need for that.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-05-10 22:01:00 +02:00

43 lines
1.9 KiB
YAML

# Lefthook configuration.
#
# Replaces the hand-rolled scripts that previously lived under
# .githooks/ and were registered via `git config core.hooksPath
# .githooks`. Behaviour is intentionally 1:1 with those scripts —
# see WS-3 session 1a notes for the migration record.
#
# The .githooks/ scripts remain on disk and contain the actual logic
# (gating against .claude-sync.conf, merge-commit handling, the
# non-blocking pre-push warning). lefthook dispatches to them so the
# delicate gating logic isn't re-translated into YAML. See
# .githooks/README.md for details.
post-commit:
commands:
sync-claude-docs:
run: bash .githooks/post-commit
pre-push:
# piped: true forces serial execution. Both sync-check and git-lfs
# read from stdin (git pipes the push refspec to pre-push hooks);
# default parallel execution deadlocks with two stdin readers.
piped: true
commands:
sync-check:
run: bash .githooks/pre-push
# Manual smoke tests need `lefthook run pre-push --force`:
# without `--force`, lefthook v2 inspects {push_files} (the
# diff between local and remote) and skips when that list is
# empty, which is always the case during a manual run. On a
# real `git push` with commits the file list is non-empty and
# the command fires — matching the legacy hook's "always runs"
# behaviour. (Pushing with zero new commits would be skipped
# under lefthook but is a no-op for the sync-staleness warning
# anyway, so behaviour stays effectively 1:1.)
git-lfs:
# `git lfs install --skip-repo` only sets up global clean/smudge
# filters — it does NOT install the per-repo pre-push hook
# (which would conflict with lefthook). We delegate the LFS
# upload step here so screenshot baselines tracked via LFS get
# pushed alongside their commits.
run: git lfs pre-push {1} {2}