goelhardik / ignore

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

Problem with Visual Studio .gitignore and folder names #31

Closed tripleacoder closed 2 years ago

tripleacoder commented 2 years ago

There is a problem with some of the Visual Studio .gitignore rules.

https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

The problem is these folder rules:

[Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ [Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ [Ll]ogs/

When I run a test in Ignore I get matches for folder names like MyLog, MyObj etc. This is an error because only the suffix in the folder name matches the rules.

Unit test example:

 [Fact]
        public void SimpleIgnore_ObjDir() => GitBasedTest(
           @"""
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
""",
           new[] { "foo/bar", "WpfObj/bar", "MyLog/foo" });

Git will not ignore these folders, but the Ignore code will.

goelhardik commented 2 years ago

@tripleacoder Thanks for reporting the issue and providing the unit test. The bug should be fixed now with the linked PR. The new nuget package (0.1.45) is published as well.