Skip to content

Fix: Keep Entire pre-push alive after Lefthook reinstalls hooks#1386

Open
stale2000 wants to merge 2 commits into
entireio:mainfrom
stale2000:codex/issue-1349-lefthook-safety-net
Open

Fix: Keep Entire pre-push alive after Lefthook reinstalls hooks#1386
stale2000 wants to merge 2 commits into
entireio:mainfrom
stale2000:codex/issue-1349-lefthook-safety-net

Conversation

@stale2000

@stale2000 stale2000 commented Jun 8, 2026

Copy link
Copy Markdown

Summary

https://entire.io/gh/stale2000/cli/session/019ea5bb-9549-7083-b95f-7ecb498cbc24

Closes #1349.

This keeps Entire's existing Git hook ownership behavior unchanged while adding a Lefthook-local safety net for the failure mode reported in the issue.

When a repository has a YAML Lefthook config, entire enable still installs the normal Entire .git/hooks/pre-push wrapper. It now also ensures lefthook-local.yml contains an entire-push-sessions pre-push command that only runs if Lefthook has reclaimed .git/hooks/pre-push and removed the Entire CLI hooks marker.

Normal state:

  • Git runs Entire's pre-push wrapper.
  • Entire chains to Lefthook.
  • The Lefthook-local fallback sees the Entire marker and does nothing.

Recovered state:

  • Lefthook has rewritten .git/hooks/pre-push.
  • Git runs Lefthook directly.
  • The Lefthook-local fallback sees the Entire marker is missing and runs entire hooks git pre-push {1} || true.

Details

  • Adds and updates lefthook-local.yml, not team-owned lefthook.yml.
  • Adds the local Lefthook config path to .git/info/exclude.
  • Preserves unrelated existing local Lefthook commands.
  • Removes only Entire's local Lefthook command from entire disable.
  • Keeps non-Lefthook hook behavior unchanged.
  • Handles .config/lefthook.yml detection in addition to the existing Lefthook config names.

Verification

Passed:

  • gofmt -w cmd/entire/cli/strategy/hook_managers.go cmd/entire/cli/strategy/hook_managers_test.go cmd/entire/cli/strategy/hooks.go cmd/entire/cli/strategy/hooks_test.go
  • /Users/stale2000/.local/share/mise/installs/golangci-lint/2.11.3/golangci-lint-2.11.3-darwin-arm64/golangci-lint run ./cmd/entire/cli/strategy/...
  • go test ./cmd/entire/cli/strategy
  • go test -tags=integration ./cmd/entire/cli/integration_test -run 'Test(UserPromptSubmit_ReinstallsOverwrittenHooks|HookOverwrite_MidTurnWipe_NextPromptRecovers)'
  • git diff --check

Manual real-Lefthook checks:

  • Verified with Lefthook v1.13.6 that lefthook-local.yml is merged into pre-push runs.
  • Verified {1} expands to the Git pre-push remote name (origin).
  • Verified the generated safety-net command calls entire hooks git pre-push origin when .git/hooks/pre-push lacks the Entire marker.
  • Verified the same command skips when .git/hooks/pre-push contains Entire CLI hooks.

Known verification gaps:

  • mise run check and mise run fmt did not reach the repo tasks because mise/aqua hit GitHub 504s while downloading ShellCheck and tmux.
  • go test ./cmd/entire/cli still has an unrelated date-sensitive failure in TestRunAuthStatus_RendersSessionsTable where the rendered local date is 2025-12-31 but the test expects 2026-01-01.

Entire Integration

This PR commit was attached to the active Codex transcript with Entire:

  • Session: 019ea5bb-9549-7083-b95f-7ecb498cbc24
  • Checkpoint: 965634231c03
  • Commit includes Entire-Checkpoint: 965634231c03
  • entire session current resolves the attached Codex session.
  • entire checkpoint list shows checkpoint 965634231c03 on this branch.
  • git push ran the Entire pre-push hook and pushed entire/checkpoints/v1 to the fork.

Lefthook can rewrite .git/hooks/pre-push after Entire wraps it, removing the session-push hook even though Entire remains enabled. Keep the existing hook ownership behavior unchanged and add a Lefthook-local fallback command that only runs when the Entire marker is absent from the active pre-push hook.

The fallback lives in lefthook-local.yml, is added to .git/info/exclude, and is removed by entire disable without disturbing unrelated local Lefthook commands.

Closes entireio#1349

Constraint: Preserve current Entire .git/hooks/pre-push wrapper behavior.

Constraint: Use Lefthook local config instead of modifying team-owned lefthook.yml.

Rejected: Surrender .git/hooks/pre-push ownership to Lefthook | would significantly change existing hook behavior.

Rejected: Require users to rerun entire enable after every Lefthook reinstall | leaves the silent session-push loss unfixed.

Confidence: high

Scope-risk: narrow

Directive: Do not remove the marker check unless another path guarantees Entire pre-push cannot run twice.

Tested: gofmt; golangci-lint run ./cmd/entire/cli/strategy/...; go test ./cmd/entire/cli/strategy; go test -tags=integration ./cmd/entire/cli/integration_test -run 'Test(UserPromptSubmit_ReinstallsOverwrittenHooks|HookOverwrite_MidTurnWipe_NextPromptRecovers)'; real Lefthook v1.13.6 local-config smoke test.

Not-tested: mise run check, blocked by GitHub 504s while downloading shellcheck and tmux via mise/aqua.
Entire-Checkpoint: 965634231c03
@stale2000 stale2000 requested a review from a team as a code owner June 8, 2026 06:20

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@stale2000 stale2000 changed the title Keep Entire pre-push alive after Lefthook reinstalls hooks Fix: Keep Entire pre-push alive after Lefthook reinstalls hooks Jun 8, 2026
Create an intentionally empty commit so the Entire/Codex git hooks can run without changing repository contents.

Constraint: User requested a test commit for hook validation
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: This commit is intentionally empty and may be reverted after hook validation
Tested: git commit --allow-empty completed
Not-tested: Full CI was not run because this commit is hook-only
Entire-Checkpoint: bb640c95beb8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

entire and lefthook fight over the pre-push hook; session push gets silently disabled

1 participant