Skip to content

feat: dim gitignored entries#110

Merged
seapagan merged 4 commits intomainfrom
feat/gitignore-dimming
Apr 3, 2026
Merged

feat: dim gitignored entries#110
seapagan merged 4 commits intomainfrom
feat/gitignore-dimming

Conversation

@seapagan
Copy link
Copy Markdown
Owner

@seapagan seapagan commented Apr 2, 2026

Summary

Add an opt-in -I / --gitignore feature that dims entries Git considers ignored instead of changing which entries are listed.

What changed

  • add the new CLI/config toggle and apply dim styling on top of the existing filename colors
  • use the ignore crate to resolve ignored paths from the active Git context
  • honor merged .gitignore files, .git/info/exclude, and the configured global excludes file
  • add integration coverage for root and nested ignore rules, unignore cases, explicit file arguments, and paths outside Git repos
  • update the docs to describe the new option and the full set of ignore sources that are checked
  • note in TODO.md that traversal should be revisited if recursion or tree output later moves to the ignore walker

Why

This makes it easier to see which files are ignored by Git without hiding them or changing the existing listing behavior, while keeping the feature opt-in and aligning the highlighted state with Git's actual ignore rules.

Summary by CodeRabbit

  • New Features

    • Added -I / --gitignore option and matching config setting (default: false) to dim entries matched by Git ignore rules.
    • Dimming follows the same sources Git uses: merged .gitignore files, .git/info/exclude and global excludes.
  • Documentation

    • Usage and configuration docs updated with the new gitignore option and examples.
  • Tests

    • Integration tests added to verify dimming behaviour and various ignore-source scenarios.

seapagan added 3 commits April 2, 2026 20:40
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2acc9a40-50bc-429c-95c6-5f36985f6fea

📥 Commits

Reviewing files that changed from the base of the PR and between 622d604 and 7de836e.

📒 Files selected for processing (2)
  • src/utils/gitignore.rs
  • tests/integration.rs
✅ Files skipped from review due to trivial changes (1)
  • tests/integration.rs

📝 Walkthrough

Walkthrough

Adds a -I/--gitignore option with config support and an ignore crate dependency; implements a cached gitignore matcher, applies ANSI dimming to ignored entries during file listing, updates CLI/config/params, and adds integration tests covering gitignore behaviours.

Changes

Cohort / File(s) Summary
Dependency Addition
Cargo.toml
Added dependency: ignore = "0.4.25".
Documentation
docs/src/config.md, docs/src/usage.md
Documented new gitignore config option and -I/--gitignore flag, describing sources used (.gitignore, .git/info/exclude, global excludes).
CLI & Config
src/cli.rs, src/structs.rs
Added gitignore: bool to Flags and Params; parsing, config conversion and merge logic updated; unit tests adjusted.
Utilities Export
src/utils.rs
Exported new gitignore submodule (pub mod gitignore;).
Gitignore Implementation
src/utils/gitignore.rs
New GitignoreCache and GitignoreMatcher: worktree detection, merged .gitignore collection, .git/info/exclude, global excludes, lazy cached matchers, and is_ignored(path,is_dir) API; includes unit tests.
File Processing
src/utils/file.rs
Integrated GitignoreCache into file-info creation flow; added dim styling for ignored entries; refactored helpers to centralise gitignore-aware creation while preserving public create_file_info signature.
Integration Tests
tests/integration.rs
Added run_and_capture_raw helper and multiple tests asserting ANSI dimming for ignored entries across scenarios (nested ignores, explicit files, not-in-worktree, info/exclude, global excludes).
TODO / Notes
TODO.md
Removed completed TODO about greying files; added note to reconsider directory traversal strategy if recursion/tree output added.

Sequence Diagram

sequenceDiagram
    participant User as User (CLI)
    participant Parser as CLI Parser
    participant Params as Params Merger
    participant FileProc as File Processor
    participant Cache as GitignoreCache
    participant Matcher as GitignoreMatcher
    participant Display as ANSI Renderer

    User->>Parser: provide paths + `-I` flag
    Parser->>Params: parse flags
    Params->>FileProc: pass merged params (gitignore=true)
    FileProc->>Cache: init / request matcher for scope
    Cache->>Matcher: lazily build matcher (worktree detection, collect ignore files)
    FileProc->>Cache: is_ignored(path, is_dir)?
    Cache->>Matcher: evaluate path against matchers
    Matcher-->>Cache: return match result (Ignored / Whitelist / None)
    Cache-->>FileProc: ignored = true/false
    alt ignored
        FileProc->>Display: wrap name with dim ANSI
    else visible
        FileProc->>Display: render normally
    end
    Display-->>User: output line
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐇 Soft paws tap on code at night,

I dim the files that hide from sight.
Through worktree roots and global rules I creep,
A gentle grey where ignored files sleep.
— Hop, the rabbit coder, hums and sleeps.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 51.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: dim gitignored entries' accurately and concisely describes the primary feature being added: making Git-ignored entries visible by dimming them in the listing output.

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

✨ 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 feat/gitignore-dimming

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.

@seapagan seapagan self-assigned this Apr 2, 2026
@seapagan seapagan added the enhancement New feature or request label Apr 2, 2026
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 2, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 46 complexity · 16 duplication

Metric Results
Complexity 46
Duplication 16

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@seapagan seapagan marked this pull request as ready for review April 2, 2026 20:35
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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/utils/gitignore.rs`:
- Around line 67-78: The loop currently uses
gitignore_matcher.matched_path_or_any_parents(relative_path, is_dir) but calls
matched(relative_path, is_dir) on git_exclude_matcher and git_global_matcher,
causing parent-directory patterns (e.g. "build/") to miss files; change the
calls on git_exclude_matcher and git_global_matcher to use
matched_path_or_any_parents(relative_path, is_dir) as well (preserving the Match
enum handling and is_dir argument) so all three sources consistently detect
patterns that apply to parent directories.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 39812e25-5eb4-4576-a928-066c1a3c02b4

📥 Commits

Reviewing files that changed from the base of the PR and between e5af800 and 622d604.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • Cargo.toml
  • TODO.md
  • docs/src/config.md
  • docs/src/usage.md
  • src/cli.rs
  • src/structs.rs
  • src/utils.rs
  • src/utils/file.rs
  • src/utils/gitignore.rs
  • tests/integration.rs

Signed-off-by: Grant Ramsay <seapagan@gmail.com>
@seapagan seapagan merged commit 152b828 into main Apr 3, 2026
5 checks passed
@seapagan seapagan deleted the feat/gitignore-dimming branch April 3, 2026 17:48
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