fix(cli): skip incremental-index outside git repos#9
fix(cli): skip incremental-index outside git repos#9jgangemi wants to merge 2 commits intosdsrss:mainfrom
Conversation
The incremental-index subcommand previously called create_dir_all on .code-graph/ from std::env::current_dir() with no check that cwd was a git repo. In multi-repo workspaces this caused stray indexes to materialize at workspace-parent directories when the PostToolUse hook fired from those directories. Add a silent bail in the main.rs dispatch when cwd has no .git, matching the prevailing hook-layer silent-skip convention (see incremental-index.js error swallowing and session-init.js ensureIndexFresh returning 'skipped'). Fixes sdsrss#8 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdded a pre-check in the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main.rs`:
- Around line 35-37: The current guard only checks for
project_root.join(".git").exists(), which misses nested directories; change it
to detect git membership by scanning ancestors of project_root (e.g., using
project_root.ancestors()) and return Ok(()) only if none of the ancestor
directories contain a .git entry; also account for worktrees where .git can be a
file by testing both existence and is_file on ancestor.join(".git"). Use the
existing project_root symbol and adjust the guard around the incremental-index
startup logic accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ee0ee750-9667-43e4-bbb4-7de949da77ec
📒 Files selected for processing (2)
claude-plugin/scripts/incremental-index.test.jssrc/main.rs
- Replace simple project_root/.git check with ancestor walk to handle subdirectories and worktrees (where .git is a file) - Add docstring coverage to main(), helper functions, and SharedStdout struct Fixes CodeRabbit feedback on sdsrss#9 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The incremental-index subcommand previously called create_dir_all
on .code-graph/ from std::env::current_dir() with no check that cwd
was a git repo. In multi-repo workspaces this caused stray indexes
to materialize at workspace-parent directories when the PostToolUse
hook fired from those directories.
Add a silent bail in the main.rs dispatch when cwd has no .git,
matching the prevailing hook-layer silent-skip convention (see
incremental-index.js error swallowing and session-init.js
ensureIndexFresh returning 'skipped').
Fixes #8
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Summary by CodeRabbit