fix: land resolve-conflicts pushes through PR pre-push hooks - #114
Merged
Conversation
Review worktree dependency installs (lefthook postinstall) rewrote the shared .git/hooks with scripts hardcoding the ephemeral worktree's node_modules path, so pushes failed once the worktree was removed — resolve-conflicts resolved conflicts locally but never landed them. - isolate worktree hooks: point core.hooksPath at the worktree's git admin dir (per-worktree config) before installDependencies, seeded with copies of the shared hooks, so postinstall rewrites stay inside the ephemeral worktree and vanish with it - conflict-resolver: hand pre-push hook failures to the agent and retry the push (bounded), folding leftover changes into the merge commit; branch races still defer/retry without burning agent runs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
devintern resolve-conflicts <pr-url>resolved conflicts but never pushed them (seen on #98). The PR's failure comments showedpush-failed: the push was rejected by the target repo's lefthook pre-push hook running inside the/tmpreview worktree.Root cause chain:
installDependencies(bun install) in the review worktree runs dependency postinstalls; lefthook's postinstall rewrites git hooks vialefthook install. A linked worktree shares.git/hookswith the user's checkout, so the user's real hooks were overwritten with scripts hardcoding the ephemeral worktree'snode_modulespath (/tmp/devintern-review-worktree-<branch>/...).Changes
Hook isolation (
src/lib/utils.ts):Utils.isolateWorktreeHooks(), called inprepareReviewWorktreebeforeinstallDependencies(both the reuse and fresh-creation paths).extensions.worktreeConfigand points per-worktreecore.hooksPathat the worktree's git admin dir (.git/worktrees/<name>/hooks), seeded with copies of the shared hooks. Postinstall rewrites are confined to the ephemeral worktree, stay valid for its pushes, and vanish with it. The dir lives outside the working tree, so it's invisible togit status,git clean, andgit add -A.Hook-failure retry (
src/lib/conflict-resolver.ts):hookErrorare handed to the agent (buildHookFixPrompt, up toMAX_HOOK_FIX_ATTEMPTS = 2), mirroring the review flow's hook fixer; leftover changes are amended into the merge commit before each retry.leaseShamoved) skips the agent entirely — the existing defer/retry handling stays authoritative, so no agent runs are burned on races.Testing
typecheck/lint/formatclean.Follow-up note
Existing local clones whose
.git/hookswere already poisoned still point at deleted worktrees (the/node_modulesfallback usually still resolves); re-runninglefthook installin affected clones restores them.