Repository navigation
fix(llm): name the repository, not the worktree, in prompt {{ repo }} - #4908
Merged
Merged
Conversation
The commit and squash prompts set `{{ repo }}` from the current
worktree's folder name, so from a linked worktree at `myrepo.feature`
they rendered `myrepo.feature`. Hooks and the worktree-path template
read the repository path's name, and the docs describe `repo` as the
repository name, constant across worktrees.
All three prompt sites (commit prompt, squash preview, squash run) now
go through one helper that reads `Repository::repo_path()`.
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.
{{ repo }}in commit and squash prompt templates now renders the repository's name in every worktree. Before, it rendered the current worktree's folder name, so a custom template run from a linked worktree at~/code/myrepo.featuregotmyrepo.feature. A hook in the same worktree getsmyrepo, and the LLM commits docs describe the variable as "Repository name".The three prompt sites (
build_commit_prompt, the squash preview, the squash run) each derived the name fromwt.root(). They now sharellm::prompt_repo_name, which readsRepository::repo_path(), the same sourcebuild_hook_contextand the worktree-path template use. The default templates don't reference{{ repo }}, so only custom templates are affected.One effect to know about: in a nested bare layout (
project/.gitwith worktrees beside it), the prompt'srepochanges from the worktree's folder name (e.g.main) to.git. That's the value hooks already get there. Naming bare repos better was discussed in #1281, #1544 and #1545, and this PR doesn't change that.The new test
test_prompt_repo_names_the_repository_from_a_linked_worktreecoverscommit --show-prompt,squash --show-prompt,squash --dry-run, and a real squash, all from a linked worktree. Onmainit fails withrepo=repo.feature; with the fix it passes. Themerge::andbare_repository::integration tests also pass locally, excepttest_merge_no_ff_signs_merge_commit, which fails the same way onmainin this sandbox (ssh refuses the test's signing key because its file permissions are too open).