#parser #glob #testing #git #ignore #path #say

deprecated bin+lib gitignore

DEPRECATED, SEE README! Pereviously, an implementation of .gitignore file parsing and glob testing in Rust

9 stable releases

Uses old Rust 2015

1.0.8 Apr 19, 2023
1.0.7 Aug 17, 2020
1.0.6 Feb 13, 2017
1.0.5 Oct 5, 2016
1.0.1 Jun 20, 2015

#30 in #say

Download history 1434/week @ 2024-07-22 1610/week @ 2024-07-29 1420/week @ 2024-08-05 1405/week @ 2024-08-12 1149/week @ 2024-08-19 1673/week @ 2024-08-26 1491/week @ 2024-09-02 1622/week @ 2024-09-09 1347/week @ 2024-09-16 1441/week @ 2024-09-23 1435/week @ 2024-09-30 1223/week @ 2024-10-07 1365/week @ 2024-10-14 1176/week @ 2024-10-21 1342/week @ 2024-10-28 1079/week @ 2024-11-04

5,082 downloads per month
Used in 17 crates (16 directly)

MIT/Apache

31KB
464 lines

gitignore.rs

⛔️ Important: This project is archived. Please don't build new software using this crate!

Project Status

I started this project to scratch a very specific itch I had to quickly check if some files were ignored — and didn't focus too much on correctness, just getting my specific issue solved at the time.

In 2017, when I was still working spuriously on this crate, I received some great feedback on issues that needed fixing for this to be useful in a wider set of scenarios. At the time in response, I committed to a fair bit of work to rework some of how this crate works internally, as I had made some poor-in-hindsight decisions on how to structure it — knowing what I know now about how it is used in the wild and the fun-fair of edge cases I didn't think about when I embarked on this journey, things would have been different, but you know what they say about hindsight!

I started working on this but the work got slower and further apart over time till basically I stopped doing much at all on this crate. Unfortunately, I had massively overestimated the time I would have available to maintain OSS stuff once I became a dad!

Now, 5 years later, I'm still seeing the odd issue crop up here and I feel it my duty to return one last time to say I am archiving this crate for the good of the community and will support you to transition to crates that actually work! It's really hard to let go of a problem, especially since it's still one I'd love to work on — but have to be honest about the time I have available to do so.

I am really sorry to those who depended on this project for their work and now have to change, but thanks for trusting me and for providing awesome feedback — it was a privilege. To those who tread this path after me, thanks for working on something fun and challenging for us all and good luck!

I wish you all the best — and let me know if I can assist you in any way to migrate elsewhere by dropping me a message using the contact details on my website.

Alternatives

The ignore Crate

The most plausible alternative to this project is of course @BurntSushi's ignore crate. This crate is what implements the ignore functionality for ripgrep, so as you can imagine Andrew has made it blazingly fast and it's been battle tested — you should use it! It also implements a lot of things correctly that this crate never did!

It doesn't yet serve neatly one of the main use-cases of this crate, which is to check whether a single file is ignored or not, as it's more focussed on walking a file tree and returning unignored files in bulk. However you could glue the raw parts together that it exposes to do this yourself, depending on your use-case:

  • Gitignore — this struct has a matched fn and a matched_path_or_any_parents fn which could be used to check files against a single ignore file, say at the root of a repo or provided dynamically.
  • WalkBuilder — this struct can be used to build a FS walker which respects all of the .gitignore files. Most will will likely want this so that you ignore things based on the ignore files not just at the root of your repo, but in nested folders too, whilst also respecting any global ignore rules as well.

If anybody is interested in picking up the baton from here, I strongly encourage you to see if this functionality could either be added to the ignore crate via PRs or to create a simple wrapper around ignore as another crate.

The git2 Crate

You could also consider using the actual Rust wrapper around libgit2 to achieve the same ends via the is_path_ignored fn, although be mindful that this performs FS operations and thus expects the files to actually exist in a well structured actual Git repository — this may not fit your use case.

Original README

If for some reason you need it, you can find the original README for this repo still available.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~48KB