.gitignore based parser implemented in C# according to the .gitignore spec 2.29.2.
The library is tested against real git status
outputs. The tests use LibGit2Sharp
for that.
Ignore can be installed from NuGet.
Install-Package Ignore
// Initialize ignore
var ignore = new Ignore();
// Add a rule
ignore.Add(".vs/");
// Add multiple rules
ignore.Add(new[] { "*.user", "obj/*" });
// Add rules fluently
ignore
.Add(".vs/")
.Add(new[] { "*.user", "obj/*" });
// Filter paths to exclude paths ignored as per the rules
var filteredFiles = ignore.Filter(new[] { ".vs/a.txt", "x.user", "obj/a.dll" });
// Check if a path is ignored
var isIgnored = ignore.IsIgnored("x.user");
Ignore uses netstandard2.1
for the main library and netcoreapp3.1
for the unit tests (Xunit).
From the root directory
dotnet build
From the root directory
dotnet test