Skip to content

feat: allow specifying the base commit for local (non-CI) diffs#260

Merged
2bndy5 merged 6 commits intomainfrom
diff-base
Feb 5, 2026
Merged

feat: allow specifying the base commit for local (non-CI) diffs#260
2bndy5 merged 6 commits intomainfrom
diff-base

Conversation

@2bndy5
Copy link
Collaborator

@2bndy5 2bndy5 commented Feb 5, 2026

Summary by CodeRabbit

  • New Features

    • Added --diff-base and --ignore-index CLI options to control base diffs and staged-file handling.
  • Documentation

    • Documented new CLI options (minimum version 1.12.0).
    • Improved CLI argument header formatting to handle missing short names.
  • Chores

    • Default test filter updated to exclude a specific test.
  • Tests

    • Tests expanded to cover diff-base and ignore-index behaviors and updated call sites.

@2bndy5 2bndy5 added the enhancement New feature or request label Feb 5, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

Walkthrough

Adds diff_base and ignore_index CLI options, threads them through git diff resolution and REST API listing, makes git diff functions generic over printable refs, adjusts diff/staging logic, updates call sites and tests, and adds CLI/docs metadata; also adds a test exclusion to .config/nextest.toml.

Changes

Cohort / File(s) Summary
CLI & Config
cpp-linter/src/cli/mod.rs, docs/cli.yml, .config/nextest.toml
Introduced diff_base: Option<String> (-b/--diff-base) and ignore_index: bool (--ignore-index) in SourceOptions; added diff-base and ignore-index inputs to docs/cli.yml; extended test filter in .config/nextest.toml to exclude test(#repo_get_sha).
Git module
cpp-linter/src/git.rs
Made get_sha generic over Display for flexible ref/depth input; added pub fn get_diff<'d, T: Display>(repo, diff_base: &Option<T>, ignore_index: bool) implementing staged vs tree diff selection and base resolution; updated parse_diff signature and accompanying tests/helpers.
REST API / GitHub
cpp-linter/src/rest_api/mod.rs, cpp-linter/src/rest_api/github/mod.rs
Propagated generic T: Display and new params (diff_base, ignore_index) into get_list_of_changed_files; CI/REST and local git paths now call get_diff(..., diff_base, ignore_index) and parse accordingly; tests and mocks updated to new signature.
Integration & Call sites
cpp-linter/src/run.rs, cpp-linter/tests/paginated_changed_files.rs
Updated call sites to pass &cli.source_options.diff_base and cli.source_options.ignore_index; tests updated to pass &None::<u8>, false where applicable.
Docs generation
docs/src/lib.rs
Refactored argument header assembly to conditionally include short option when present, avoiding errors when short names are absent.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

documentation

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding support for specifying the base commit for local diffs, which aligns with the changeset's primary objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch diff-base

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 and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 94.57364% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.90%. Comparing base (6002ba2) to head (eb3d529).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cpp-linter/src/git.rs 92.78% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
- Coverage   97.04%   96.90%   -0.14%     
==========================================
  Files          14       14              
  Lines        3078     3167      +89     
==========================================
+ Hits         2987     3069      +82     
- Misses         91       98       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Feb 5, 2026

@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
- Coverage   97.04%   96.90%   -0.14%     
==========================================
  Files          14       14              
  Lines        3078     3167      +89     
==========================================
+ Hits         2987     3069      +82     
- Misses         91       98       +7     

The 7 lines missing coverage are all related to providing better error messages. There's little benefit in adding tests that cover these lines.

2bndy5 and others added 2 commits February 5, 2026 04:01
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@2bndy5 2bndy5 merged commit af0328a into main Feb 5, 2026
65 checks passed
@2bndy5 2bndy5 deleted the diff-base branch February 5, 2026 21:10
2bndy5 added a commit to cpp-linter/cpp-linter that referenced this pull request Feb 6, 2026
In porting #180 to rust (cpp-linter/cpp-linter-rs#260),
I found a few spots for improvement.
These changes should be more performant when
there are staged changes.
2bndy5 added a commit to cpp-linter/cpp-linter that referenced this pull request Feb 6, 2026
In porting #180 to rust (cpp-linter/cpp-linter-rs#260),
I found a few spots for improvement.
These changes should be more performant when
there are staged changes.
2bndy5 added a commit to cpp-linter/cpp-linter that referenced this pull request Feb 6, 2026
In porting #180 to rust (cpp-linter/cpp-linter-rs#260),
I found a few spots for improvement.
These changes should be more performant when
there are staged changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant