Skip to content

Refactor git branch#8

Merged
b4prog merged 2 commits into
mainfrom
refactor-git-branch
Jun 27, 2026
Merged

Refactor git branch#8
b4prog merged 2 commits into
mainfrom
refactor-git-branch

Conversation

@b4prog

@b4prog b4prog commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Duplicate-code search with the git-branch option now focuses on files changed on the current local branch.
  • Documentation
    • Updated the git-branch help text and README to better explain the branch-based search behavior and Git requirements.
  • Chores
    • Bumped the package version to 0.7.1.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR bumps the crate version, rewrites --git-branch documentation/help text, and changes duplicate reporting so git-branch mode filters processed files before duplicate scanning. Test scaffolding and the git-branch duplicate-search test were updated to match the new path handling.

Changes

Git-branch duplicate search update

Layer / File(s) Summary
Version and branch option text
Cargo.toml, README.md, src/cli/help.rs
Cargo.toml bumps the package version to 0.7.1, and the git-branch option text in the README and help output is shortened to describe scanning duplicate code only in current local branch changes.
Git-branch file filtering
src/lib.rs
run now gathers git_branch_files separately, passes None into source discovery in git-branch mode, and derives duplicate_source_files by filtering processed files through filtered_processed_files before duplicate detection and timing.
Git test scaffolding
src/lib.rs
TempProject/TempGitRepo plumbing and run_in accept generic AsRef<Path> inputs, and the git_branch_mode_limits_duplicate_search_to_changed_files test is updated to use the revised helpers.

Estimated review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • b4prog/CodeM8#2: Changes the same src/lib.rs duplicate-report path and timing plumbing that this PR also updates.
  • b4prog/CodeM8#7: Refactors the duplicate-report discovery/report APIs that the current git-branch filtering logic builds on.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the git-branch work but too vague to describe the main behavior change. Rename it to state the specific change, e.g. "Limit git-branch searches to changed files on the current branch".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-git-branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/lib.rs (2)

178-236: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: deduplicate TempProject / TempGitRepo scaffolding.

new, write, Drop, and AsRef<Path> are essentially identical between the two helpers; only git/commit are unique to TempGitRepo. Extracting a shared temp-dir helper (e.g. TempGitRepo wrapping a TempProject) 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 win

Strengthen the git-branch scoping assertions.

This test only asserts Duplicate blocks found: 0, which would also pass if filtered_processed_files matched nothing (e.g. a path-format mismatch between changed_files_against_origin output and display_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::git uses Command::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

📥 Commits

Reviewing files that changed from the base of the PR and between 904b59d and e2240aa.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • Cargo.toml
  • README.md
  • src/cli/help.rs
  • src/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 Correctness

git-branch mode is intentionally changed-files only.
-git-branch searches 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.

@b4prog b4prog merged commit 65e78be into main Jun 27, 2026
4 checks passed
@b4prog b4prog deleted the refactor-git-branch branch June 27, 2026 13:11
This was referenced Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant