goelhardik / ignore

.gitignore based parser implemented in C# according to the .gitignore spec 2.29.2.
MIT License
50 stars 5 forks source link

Ignore does not recognize the difference between rooted and non-rooted paths #44

Open JKamsker opened 10 months ago

JKamsker commented 10 months ago

Pr https://github.com/goelhardik/ignore/pull/43/files displays the error

mitchcapper commented 7 months ago

Further it likely should allow setting the root for comparisons. If I read a .gitignore in it would be useful to be able to set the root that file is found in. That way paths passed are first converted relative to that root.

IE if var ignore = new Ignore(Root="c:/Data/MyRepo"); and then called with ignore.IsIgnored("c:/Data/MyRepo/bob/first"); it should test /bob/first as the path.

This is pretty easy to do if you use System.IO.Path.GetRelativePath