Show parent project name in worktree status line#25
Conversation
When running in a git worktree, the status line now shows ⎇ projectName/worktreeName instead of just ⎇ worktreeName, by parsing the .git file to trace back to the main repository. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the user experience when working with Git worktrees by providing more contextual information directly in the status line. By displaying the parent repository's name alongside the worktree's name, users can more easily identify their current Git context, especially when managing multiple worktrees across different projects. The changes include robust parsing of Git metadata and a caching mechanism to ensure this enhancement does not negatively impact performance. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request enhances the status line for Git worktrees by displaying the parent project name, which is a great improvement for clarity. The implementation correctly parses the .git file to trace back to the main repository and thoughtfully includes caching to optimize performance. The tests have been updated appropriately, and new tests cover the added functionality. I have one suggestion to make the repository name parsing more robust in edge cases.
internal/statusline/statusline.go
Outdated
| // e.g. /path/to/main-repo/.git/worktrees/name → /path/to/main-repo | ||
| sep := string(filepath.Separator) | ||
| marker := sep + ".git" + sep | ||
| idx := strings.Index(gitdir, marker) |
There was a problem hiding this comment.
Using strings.LastIndex here would be more robust. The gitdir path points into the main repository's .git directory structure (.../main-repo/.git/worktrees/name). We want to find the .git directory of the main repository.
If a parent directory in the path happens to be named .git (e.g., /path/to/a.git/project/.git/worktrees/...), strings.Index would find the first /.git/ segment, leading to an incorrect main repository name (a.git instead of project).
Using strings.LastIndex ensures you find the .git directory that is closest to the worktrees directory in the path, which is the correct one for the main repository.
| idx := strings.Index(gitdir, marker) | |
| idx := strings.LastIndex(gitdir, marker) |
Handles edge case where a parent directory contains .git in its name (e.g., /path/to/a.git/project/.git/worktrees/name). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
⎇ projectName/worktreeNameinstead of just⎇ worktreeName.gitfile (gitdir: /path/to/main/.git/worktrees/name) to trace back to the main repositoryWorktreeTTL(5 min) to avoid repeated filesystem readsTest plan
go test ./internal/statusline/ -run "Worktree|MainRepo|RenderDir" -v)go build ./cmd/prism/)claude --worktreeand confirm status line shows⎇ projectName/worktreeName🤖 Generated with Claude Code