Skip to content

This opens a clean PR to fix #60. Should close old PR #61#62

Merged
peteretelej merged 8 commits into
peteretelej:mainfrom
Simar-malhotra09:re-pattern-flag
Mar 14, 2026
Merged

This opens a clean PR to fix #60. Should close old PR #61#62
peteretelej merged 8 commits into
peteretelej:mainfrom
Simar-malhotra09:re-pattern-flag

Conversation

@Simar-malhotra09

@Simar-malhotra09 Simar-malhotra09 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

The latest commit adds new integration tests and fixes prev issue with --fromfile flag

Summary by CodeRabbit

  • New Features

    • Accept multiple include/exclude patterns via repeated -P/-I flags and support pipe-separated alternatives per flag.
  • Refactor

    • Unified and simplified pattern handling to treat multiple patterns consistently and skip filtering when none provided.
  • Tests

    • Expanded and reorganized tests covering multi-pattern, pipe-separated, directory-matching, and prune interactions.

@coderabbitai

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Simar-malhotra09 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf7f0d28-c971-4a00-9c72-0168a1984805

📥 Commits

Reviewing files that changed from the base of the PR and between f36acae and c0d094e.

📒 Files selected for processing (2)
  • src/rust_tree/cli.rs
  • src/rust_tree/traversal.rs
📝 Walkthrough

Walkthrough

Refactors pattern handling: pattern_glob changes from Option<Pattern> to Vec<Pattern>. CLI accepts multiple -P/-I flags and pipe-separated patterns; parsing flattens and trims fragments. Downstream traversal and tests updated to treat an empty Vec as “no patterns.”

Changes

Cohort / File(s) Summary
CLI Pattern Parsing
src/rust_tree/cli.rs
Changed Cli.pattern from Option<String> to Vec<String>; parse multiple -P/-I occurrences and split pipe-separated segments, trimming and filtering empty fragments.
Core Data Structure
src/rust_tree/options.rs
Changed TreeOptions.pattern_glob from Option<Pattern> to Vec<Pattern> (empty vec represents no patterns).
Pattern Matching Logic
src/rust_tree/traversal.rs
Reworked filtering to treat pattern_glob as a collection: added dir_matches_pattern helper, use is_empty() checks and iter().any(...) for matches; updated recursion/prune logic to use the new semantics.
Unit & CLI Tests
tests/cli_unit_tests.rs, tests/unit_tests.rs, tests/traversal_tests.rs
Updated initializations and assertions: Nonevec![], Some(Pattern::new(...))vec![Pattern::new(...)]; replace is_some()/is_none() checks with is_empty()/non-empty checks.
Integration Tests
tests/integration_tests.rs
Renamed test_pattern_matchingtest_include_pattern_matching; added test_exclude_pattern_matching; expanded scenarios covering multiple -P flags, pipe-separated patterns, --matchdirs, --prune, and edge-case pipes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • peteretelej

Poem

🐰 I hopped through pipes and split the thread,
From single seed to many spread.
Patterns bloom in tidy rows,
Empty basket means none chose —
Now filters dance where vectors tread. 🌱✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title references fixing issue #60 and closing PR #61, but does not clearly describe the actual technical changes made (converting pattern flag from optional string to vector of strings, supporting multiple patterns). Use a more descriptive title that summarizes the main technical change, such as 'Support multiple patterns via -P and -I flags' or 'Refactor pattern matching to accept multiple pattern arguments'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/integration_tests.rs (1)

363-380: ⚠️ Potential issue | 🟠 Major

Fix copy-paste bug: assertions use wrong variable names.

The assertions at lines 364-365 and 379-380 reference output_pipe_exclude but should reference the local variables output_pipe_edges and output_double_pipe respectively. This may cause the tests to pass coincidentally while not actually validating the intended behavior.

🐛 Proposed fix
     assert!(output_not_contains(&output_pipe_edges, "src"));
     assert!(output_not_contains(&output_pipe_edges, "docs"));
 
     // Other entries should still exist
-    assert!(output_contains(&output_pipe_exclude, "tests"));
-    assert!(output_contains(&output_pipe_exclude, "README.md"));
+    assert!(output_contains(&output_pipe_edges, "tests"));
+    assert!(output_contains(&output_pipe_edges, "README.md"));
 
     // Consecutive pipes (empty segment between them) should be ignored
     let output_double_pipe = cmd()
         .args(["-I", "src||docs", temp_dir.path().to_str().unwrap()])
         .assert()
         .success()
         .get_output()
         .stdout
         .clone();
     assert!(output_not_contains(&output_double_pipe, "src"));
     assert!(output_not_contains(&output_double_pipe, "docs"));
 
     // Other entries should still exist
-    assert!(output_contains(&output_pipe_exclude, "tests"));
-    assert!(output_contains(&output_pipe_exclude, "README.md"));
+    assert!(output_contains(&output_double_pipe, "tests"));
+    assert!(output_contains(&output_double_pipe, "README.md"));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration_tests.rs` around lines 363 - 380, Fix the copy-paste
mistake in the test assertions: replace the incorrect references to
output_pipe_exclude with the correct local variables — use output_pipe_edges for
the assertions validating the pipe-edge behavior and output_double_pipe for the
assertions validating consecutive-pipe behavior; specifically update the calls
to output_contains and output_not_contains that currently reference
output_pipe_exclude so they instead reference output_pipe_edges and
output_double_pipe respectively (these variables are defined near the
cmd().args(...) blocks and paired with output_contains/output_not_contains
assertions).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/integration_tests.rs`:
- Around line 315-321: The formatting error is caused by incorrect blank lines
around the test declaration: ensure there is exactly one blank line before the
#[test] attribute for the function test_exclude_pattern_matching and remove the
stray extra blank line after the call to create_test_structure() inside that
test; then run cargo fmt to apply formatting across the crate so the pipeline
passes.

---

Outside diff comments:
In `@tests/integration_tests.rs`:
- Around line 363-380: Fix the copy-paste mistake in the test assertions:
replace the incorrect references to output_pipe_exclude with the correct local
variables — use output_pipe_edges for the assertions validating the pipe-edge
behavior and output_double_pipe for the assertions validating consecutive-pipe
behavior; specifically update the calls to output_contains and
output_not_contains that currently reference output_pipe_exclude so they instead
reference output_pipe_edges and output_double_pipe respectively (these variables
are defined near the cmd().args(...) blocks and paired with
output_contains/output_not_contains assertions).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 65f9fb34-7cb9-4f42-adcd-0e0a49db1812

📥 Commits

Reviewing files that changed from the base of the PR and between e72793e and 6e32afb.

📒 Files selected for processing (7)
  • src/rust_tree/cli.rs
  • src/rust_tree/options.rs
  • src/rust_tree/traversal.rs
  • tests/cli_unit_tests.rs
  • tests/integration_tests.rs
  • tests/traversal_tests.rs
  • tests/unit_tests.rs

Comment thread tests/integration_tests.rs Outdated

@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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tests/integration_tests.rs (1)

342-344: ⚠️ Potential issue | 🟡 Minor

Run cargo fmt here.

There is still no blank line between the end of test_include_pattern_matching and the next #[test], which is the same formatting issue previously flagged on this file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration_tests.rs` around lines 342 - 344, The file is missing a
blank line between the end of the test_include_pattern_matching function and the
next test annotation; open tests/integration_tests.rs, locate the closing brace
of test_include_pattern_matching and the next #[test] for
test_exclude_pattern_matching, and insert a single blank line (or simply run
rustfmt via cargo fmt) so there is one empty line separating the two tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/integration_tests.rs`:
- Around line 182-341: The test suite is missing a case that verifies repeating
include/exclude flags are flattened (cli_to_options collects a Vec<Pattern>);
add one integration test using repeated -P (e.g. cmd().args(["--prune", "-P",
"*.rs", "-P", "*.md", temp_dir.path().to_str().unwrap()]) ) and one using
repeated -I or -P for directories (e.g. cmd().args(["-I", "src", "-I", "docs",
...])) that assert combined behavior via the existing helpers
output_contains/output_not_contains and cmd()/get_output(), ensuring patterns
from multiple occurrences are applied rather than only the last occurrence.

---

Duplicate comments:
In `@tests/integration_tests.rs`:
- Around line 342-344: The file is missing a blank line between the end of the
test_include_pattern_matching function and the next test annotation; open
tests/integration_tests.rs, locate the closing brace of
test_include_pattern_matching and the next #[test] for
test_exclude_pattern_matching, and insert a single blank line (or simply run
rustfmt via cargo fmt) so there is one empty line separating the two tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: da2f291a-c1e7-47b0-acd4-243c9e5ce2ad

📥 Commits

Reviewing files that changed from the base of the PR and between 6e32afb and f36acae.

📒 Files selected for processing (1)
  • tests/integration_tests.rs

Comment thread tests/integration_tests.rs

@peteretelej peteretelej left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

lgtm. ty

@peteretelej peteretelej added the bug Something isn't working label Mar 14, 2026
@peteretelej
peteretelej merged commit 40f035e into peteretelej:main Mar 14, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants