dcdpr / dcdpr/jp

Unify includes and excludes into single ordered pattern list

Open
#195 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
16
Forks
3
Avg merge
1d 1h
Merged PRs (30d)
121

Description

The file content attachment handler should not separate includes and excludes into separate collections, but instead maintain a single ordered list of patterns where order matters for precedence, similar to how gitignore files work.

Context

Currently, the FileContent struct maintains separate BTreeSet<Pattern> collections for includes and excludes. However, this approach doesn't align with how gitignore patterns work, where the order of patterns matters for precedence.

In gitignore syntax, patterns are evaluated in order, and later patterns can override earlier ones. For example:

  • foo/ (exclude all foo directories)
  • !foo/important.txt (but include this specific file)

The current approach makes it impossible to have proper precedence because includes and excludes are processed separately, and the CLI argument order (-a one -a two) should be preserved so that two is processed after one.

Proposed Implementation

  1. Replace the separate includes and excludes fields with a single patterns: Vec<(Pattern, bool)> where the boolean indicates whether it's an include (true) or exclude (false) pattern.

  2. Modify the add method to append patterns to this vector in order, preserving the CLI argument sequence.

  3. Update the get method to process patterns in order when building the OverrideBuilder.

  4. Update the list method to return patterns in their original order.

  5. Update the serialization to preserve order (using Vec instead of BTreeSet).

Resources

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in crates/jp_attachment_file_content/src/lib.rs, especially the FileContent fields and its add, get, and list methods. Trace how OverrideBuilder and serialization use the patterns, then verify that CLI argument order and serialized output preserve precedence and original ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.