Repository navigation
Use the repository's worktree directory when Herdr does not name it - #602
Open
thiblahute wants to merge 1 commit into
Open
thiblahute wants to merge 1 commit into
thiblahute wants to merge 1 commit into
Conversation
Herdr's workspace.get does not always describe the workspace's repository (no worktree.repo_key), for a workspace opened outside a checkout or one it has not inspected yet. Worktree creation then looked up the repository's settings under the source checkout's path, missed the configured worktree directory and fell back to Herdr's default ~/.herdr/worktrees/<checkout name>/<branch>. Ask git for the root's common directory in that case, the key Herdr uses, so that a worktree created from any checkout of a repository, the main one or a linked worktree, lands in its worktree directory and runs its worktree command. Settings saved under a checkout path keep applying. Resolve that key in one place, resolveRepoSettingsKey, and use it for creation, Ranger's confirmation and the settings dialogs: the Worktree Location dialog and the worktree hooks settings showed and saved the checkout path's settings, and Ranger confirmed the command under that key, so creation refused it as changed.
This branch has not been deployed
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.
Summary
Create a worktree in the repository's configured worktree directory even when Herdr does not say which repository the source workspace belongs to. A follow-up to #550.
Why
Herdr's
workspace.getdoes not always carryworktree.repo_key: a workspace opened outside a checkout, or one Herdr has not inspected yet, has none. Worktree creation then looked up the repository's settings under the source checkout's path, missed the worktree directory (and command) set for the repository, and fell back to Herdr's default~/.herdr/worktrees/<checkout name>/<branch>.The settings dialogs had the same gap: the Worktree Location dialog and the worktree hooks settings showed and saved the checkout path's settings, and Ranger confirmed a worktree command under that key, so creation then refused it as changed.
What changed
server/src/worktree/create.ts:resolveRepoSettingsKeynames the repository when Herdr does not, by asking git for the checkout's common directory (git rev-parse --path-format=absolute --git-common-dir, over SSH for remote hosts), the key Herdr uses. Every checkout of a repository, the main one or a linked worktree, then shares its settings. Settings already saved under a checkout path keep applying. The default checkout path takes the repository's name from that directory too.server/src/bridge/settings-rpc.ts: the worktree location and worktree hooks RPCs use the same key, so the dialogs show and save what creation applies.server/src/assistant/actions.ts: Ranger's worktree confirmation uses the same key.docs/DEPLOYMENT.md: the worktree location is shared by every checkout of the repository.Verification
bun test server/src/worktree/create.test.ts server/src/assistant/actions.test.ts server/src/bridge/settings-rpc.test.ts: 152 pass. New tests: a workspace Herdr reports no repository for uses its repository's directory; a worktree command defaults under the repository's name, not the linked checkout's; settings saved under the checkout path still apply; a repository Herdr reports is not asked of git; the settings RPC and Ranger's confirmation use the repository's key. Four of them fail onmain.bun run format:check,bun run lint(only the existingTerminalView.tsxwarning),bun run typecheck:bun,bun run test:quickwith an isolatedHOME/TMPDIR.Manual checks