Conversation
Summary of ChangesHello @jdx, 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 enhances the Highlights
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 introduces support for git worktrees by adding a new git_util module to correctly resolve the git hooks directory, which is necessary because .git is a file in worktrees. The install and uninstall commands are updated to use this new utility, fixing failures in worktree environments. The changes are well-tested with a new worktree.bats test suite. My review includes a suggestion to improve the robustness of path resolution in an edge case and another to refactor duplicated code into a shared helper function for better maintainability. Overall, this is a valuable improvement to the tool.
| let cwd = std::env::current_dir()?; | ||
| let git_path = xx::file::find_up(&cwd, &[".git"]) | ||
| .ok_or_else(|| eyre::eyre!("No .git found in this or any parent directory"))?; |
There was a problem hiding this comment.
This logic to find the .git path is also present in src/cli/install.rs. To improve maintainability and reduce code duplication, consider extracting this logic into a new helper function within the git_util module.
For example, you could add this function to src/git_util.rs:
pub fn find_git_path_from_cwd() -> Result<PathBuf> {
let cwd = std::env::current_dir()?;
xx::file::find_up(&cwd, &[".git"])
.ok_or_else(|| eyre::eyre!("No .git found in this or any parent directory"))
}Then, both install.rs and uninstall.rs could simply call let git_path = git_util::find_git_path_from_cwd()?;.
| git_path | ||
| .parent() | ||
| .unwrap_or(Path::new(".")) | ||
| .join(&gitdir_path) |
There was a problem hiding this comment.
Using unwrap_or with Path::new(".") could lead to incorrect behavior in the unlikely edge case where git_path.parent() returns None. This could happen if .git is at the filesystem root and the current working directory is different. It's more robust to return an error in this case. Consider using ok_or_else to handle the None case and provide a clear error message.
| git_path | |
| .parent() | |
| .unwrap_or(Path::new(".")) | |
| .join(&gitdir_path) | |
| git_path | |
| .parent() | |
| .ok_or_else(|| eyre!("could not determine parent directory of .git file: {}", git_path.display()))? | |
| .join(&gitdir_path) |
d169c58 to
c69890a
Compare
In git worktrees, .git is a file containing a gitdir pointer rather than a directory. Resolve the actual git dir and hooks path by parsing this file when needed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c69890a to
2ea4640
Compare
### 🚀 Features - **(init)** add auto-detection and interactive mode by [@jdx](https://github.com/jdx) in [#656](#656) - **(stash)** use haiku names for stash patch backups by [@jdx](https://github.com/jdx) in [#655](#655) - add git worktree support by [@jdx](https://github.com/jdx) in [#651](#651) - add "did you mean?" suggestions for typos by [@jdx](https://github.com/jdx) in [#654](#654) ### 🚜 Refactor - use xx utilities and drop unused dependencies by [@jdx](https://github.com/jdx) in [#653](#653) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk release bookkeeping: mainly version string/package URL updates and regenerated CLI docs, with no substantive runtime logic changes. > > **Overview** > Releases **v1.35.0** by updating crate versions (`Cargo.toml`/`Cargo.lock`) and adding the `1.35.0` entry to `CHANGELOG.md`. > > Regenerates documentation and examples to reference `v1.35.0` package URLs and CLI version metadata, and updates `hk init` docs/usage to include the new `--interactive` flag. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 46c426e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: mise-en-dev <123107610+mise-en-dev@users.noreply.github.com>
Summary
.gitis a file (not a directory) containing agitdir:pointer. hk assumed.gitis always a directory, causinghk installto fail with "Not a directory (os error 20)" and hooks not being found by git.src/git_util.rswith helpers to resolve the actual git dir, common git dir (viacommondirfile), and hooks path — ensuring hooks are installed to the common.git/hooks/directory where git actually looks for them, not the worktree-specific subdirectory.installanduninstallcommands to use the resolved hooks directory.Test plan
test/worktree.batswith 6 tests:hk installin a worktreehk uninstallin a worktreehk checkin a worktreehk fixin a worktreegit commitin a worktreehk run pre-commitin a worktreeinstall_warn_hookspath.batstests still pass🤖 Generated with Claude Code
Note
Medium Risk
Medium risk because it changes how
hk install/hk uninstalllocate and modify git hooks, including new path resolution logic for worktrees; incorrect resolution could install/remove hooks in the wrong repo location.Overview
hk install/hk uninstallnow locate the repository’s hooks directory via a newgit_utilhelper instead of assuming.gitis a directory at./.git/hooks, enabling correct behavior in git worktrees.Adds
src/git_util.rsto resolve.gitwhen it is agitdir:pointer file and to followcommondirso hooks are written to the common hooks directory. Includes a newtest/worktree.batssuite covering install/uninstall,check/fix, and that hooks actually fire in a worktree.Written by Cursor Bugbot for commit 2ea4640. This will update automatically on new commits. Configure here.