Refactor git branch#8
Conversation
📝 WalkthroughWalkthroughThe PR bumps the crate version, rewrites ChangesGit-branch duplicate search update
Estimated review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (2)
src/lib.rs (2)
178-236: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: deduplicate
TempProject/TempGitReposcaffolding.
new,write,Drop, andAsRef<Path>are essentially identical between the two helpers; onlygit/commitare unique toTempGitRepo. Extracting a shared temp-dir helper (e.g.TempGitRepowrapping aTempProject) would remove the duplication.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib.rs` around lines 178 - 236, `TempGitRepo` duplicates the temp-directory setup and file-writing lifecycle already present in `TempProject`; extract the shared behavior into a common temp helper and have `TempGitRepo` compose or wrap it. Keep the unique `git` and `commit` methods on `TempGitRepo`, while reusing the shared `new`, `write`, `Drop`, and `AsRef<Path>` behavior through the common helper to remove the repeated scaffolding.
362-379: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winStrengthen the git-branch scoping assertions.
This test only asserts
Duplicate blocks found: 0, which would also pass iffiltered_processed_filesmatched nothing (e.g. a path-format mismatch betweenchanged_files_against_originoutput anddisplay_path). To actually verify scoping works as intended, add a positive case where two changed files duplicate each other (expect a duplicate) alongside this negative case, so the filter's correctness — not just its presence — is covered.Separately,
TempGitRepo::gitusesCommand::status(), which inherits stdout/stderr and prints git output during the test run;Command::output()would keep the test quiet while still allowing the success assertion.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib.rs` around lines 362 - 379, The git-branch scoping test only checks that no duplicates are reported, so it could pass even if the changed-file filter matches nothing; update git_branch_mode_limits_duplicate_search_to_changed_files to include a positive case with two changed files that duplicate each other and assert a duplicate is found, while keeping the existing negative case for non-changed files. Also adjust TempGitRepo::git to use Command::output instead of Command::status so git output stays quiet while still asserting success.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/lib.rs`:
- Around line 178-236: `TempGitRepo` duplicates the temp-directory setup and
file-writing lifecycle already present in `TempProject`; extract the shared
behavior into a common temp helper and have `TempGitRepo` compose or wrap it.
Keep the unique `git` and `commit` methods on `TempGitRepo`, while reusing the
shared `new`, `write`, `Drop`, and `AsRef<Path>` behavior through the common
helper to remove the repeated scaffolding.
- Around line 362-379: The git-branch scoping test only checks that no
duplicates are reported, so it could pass even if the changed-file filter
matches nothing; update git_branch_mode_limits_duplicate_search_to_changed_files
to include a positive case with two changed files that duplicate each other and
assert a duplicate is found, while keeping the existing negative case for
non-changed files. Also adjust TempGitRepo::git to use Command::output instead
of Command::status so git output stays quiet while still asserting success.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4d784f26-0327-4e06-80d0-0c1fb1f09505
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
Cargo.tomlREADME.mdsrc/cli/help.rssrc/lib.rs
📜 Review details
🔇 Additional comments (7)
Cargo.toml (1)
3-3: LGTM!README.md (1)
87-90: LGTM!src/cli/help.rs (2)
32-33: LGTM!
70-86: LGTM!src/lib.rs (3)
10-17: LGTM!
113-128: LGTM!
55-61: 🎯 Functional Correctnessgit-branch mode is intentionally changed-files only.
-git-branchsearches duplicate code only within files changed on the current branch, so unchanged-file matches are out of scope for this mode.> Likely an incorrect or invalid review comment.
Summary by CodeRabbit
git-branchoption now focuses on files changed on the current local branch.git-branchhelp text and README to better explain the branch-based search behavior and Git requirements.0.7.1.