EasyRepository SystemsPython 3
Repository Ignore Filter
Filter repository paths with simple ordered ignore and re-include rules.
30m2 sample tests5 hidden tests
Implement filter_repo_paths(paths, rules), a small .cursorignore-style path filter.
Requirements
- Preserve the original order of kept paths.
- Reject invalid paths with empty segments,
.segments, or..traversal. - Blank rules and rules starting with
#are ignored. - A rule ending in
/ignores every path under that directory prefix. - A rule without
/matches an exact file path. - A rule starting with
!re-includes paths matched by earlier rules. - Later matching rules win.
Example
python
1paths = ["src/app.py", "node_modules/lib.js", "dist/app.js"]
2rules = ["node_modules/", "dist/"]
3assert filter_repo_paths(paths, rules) == ["src/app.py"]Constraints
- No glob engine is required.
- Keep matching deterministic and easy to explain.
Editor