Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Add more flexible ignore matching for full ignore rule#385

Merged
jhaynie merged 1 commit intomainfrom
better-pattern-matching
Jun 12, 2025
Merged

Add more flexible ignore matching for full ignore rule#385
jhaynie merged 1 commit intomainfrom
better-pattern-matching

Conversation

@jhaynie
Copy link
Copy Markdown
Member

@jhaynie jhaynie commented Jun 12, 2025

For bundling, we aren't ignore enough files with the rules we have. In a JS bundle case, we can pretty much exclude everything except the agentuity.yaml and the .agentuity directory to keep things as slim as possible. This will enable the ability to change the templates to be more aggressive in ignoring files.

We need to roll this out (and force upgrade) before we can roll out the template changes.

Summary by CodeRabbit

  • New Features
    • Improved file ignore rules to support a "full wildcard" pattern, allowing all files to be ignored by default and selectively included using negated rules.
  • Bug Fixes
    • Enhanced handling of negated and wildcard ignore patterns for more flexible file inclusion and exclusion.
  • Tests
    • Added comprehensive tests to verify correct behavior of negated and wildcard ignore rules in various scenarios.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 12, 2025

Walkthrough

A new mechanism was implemented in the ignore rules logic to support "full wildcard" patterns (**/*) that ignore all files by default, allowing selective inclusion via negated rules. This required changes to pattern parsing, ignore evaluation, and the addition of related tests. A String() method was also added for rule inspection.

Changes

File(s) Change Summary
cmd/cloud.go Added a blank line before a return statement in createProjectIgnoreRules; no logic or behavior changes.
internal/ignore/rules.go Added String() method to Rules. Enhanced ignore logic to support **/* full wildcard with negation. Updated pattern struct.
internal/ignore/rules_test.go Added multiple tests covering negated patterns, full wildcard rules, and their combinations in various orders.

Poem

In the warren of wildcards, rules now play,
Ignore all, then let exceptions sway.
Negations hop in, with a clever twist,
Only the chosen files make the list.
With tests galore and logic anew,
This bunny’s code now hops right through!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch better-pattern-matching
  • Post Copyable Unit Tests in Comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@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: 0

🧹 Nitpick comments (1)
internal/ignore/rules_test.go (1)

41-48: Consider checking error returns from rules.Add()

While the existing tests don't check errors either, it would be more robust to verify that rules are added successfully.

 func TestNegateRules(t *testing.T) {
 	rules := Empty()
 	rules.AddDefaults()
-	rules.Add("!**/foo.py")
+	err := rules.Add("!**/foo.py")
+	assert.NoError(t, err)
 	assert.False(t, rules.Ignore("/Users/foobar/example/src/foo.py", nil))
 	assert.False(t, rules.Ignore("foo.py", nil))
 	assert.True(t, rules.Ignore("bar.py", nil))
 }
🧰 Tools
🪛 golangci-lint (1.64.8)

44-44: Error return value of rules.Add is not checked

(errcheck)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 004258a and 28eff08.

📒 Files selected for processing (3)
  • cmd/cloud.go (1 hunks)
  • internal/ignore/rules.go (6 hunks)
  • internal/ignore/rules_test.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/ignore/rules_test.go (1)
internal/ignore/rules.go (2)
  • Empty (51-53)
  • Ignore (40-40)
🪛 golangci-lint (1.64.8)
internal/ignore/rules_test.go

44-44: Error return value of rules.Add is not checked

(errcheck)


53-53: Error return value of rules.Add is not checked

(errcheck)


54-54: Error return value of rules.Add is not checked

(errcheck)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test CLI Upgrade Path (windows-latest)
  • GitHub Check: Analyze (go)
🔇 Additional comments (5)
cmd/cloud.go (1)

151-151: LGTM!

The blank line improves readability by separating the rule processing logic from the return statement.

internal/ignore/rules.go (3)

55-61: String() method implementation looks good

The implementation efficiently concatenates patterns using bytes.Buffer and provides a useful debugging/inspection capability.


160-166: Special handling for full wildcard pattern is well implemented

The logic correctly implements the "ignore everything by default, then selectively include" pattern when **/* is the first rule. This is a useful feature for projects that want to be explicit about what to include.


216-233: Full wildcard pattern parsing correctly implements the special behavior

The implementation properly handles the **/* pattern by placing it first and filtering out non-negated patterns. Note that when **/* is encountered, any non-negated patterns that appear before it in the file are discarded, keeping only negated patterns.

internal/ignore/rules_test.go (1)

50-93: Excellent test coverage for the new full wildcard functionality

The tests comprehensively verify the behavior of **/* pattern in various scenarios, including different ordering relative to negated patterns. This ensures the feature works correctly regardless of how rules are arranged in ignore files.

🧰 Tools
🪛 golangci-lint (1.64.8)

53-53: Error return value of rules.Add is not checked

(errcheck)


54-54: Error return value of rules.Add is not checked

(errcheck)

@jhaynie jhaynie merged commit ffadd41 into main Jun 12, 2025
14 checks passed
@jhaynie jhaynie deleted the better-pattern-matching branch June 12, 2025 17:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant