https://github.com/goelhardik/ignore
.gitignore based parser implemented in C# according to the .gitignore spec 2.29.2.
https://github.com/goelhardik/ignore
csharp gitignore glob nuget parser
Last synced: 12 months ago
JSON representation
.gitignore based parser implemented in C# according to the .gitignore spec 2.29.2.
- Host: GitHub
- URL: https://github.com/goelhardik/ignore
- Owner: goelhardik
- License: mit
- Created: 2020-12-08T03:04:53.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-18T14:53:57.000Z (almost 2 years ago)
- Last Synced: 2025-06-15T03:01:47.145Z (about 1 year ago)
- Topics: csharp, gitignore, glob, nuget, parser
- Language: C#
- Homepage:
- Size: 75.2 KB
- Stars: 55
- Watchers: 4
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ignore

[](https://codecov.io/gh/goelhardik/ignore)
[](https://www.nuget.org/packages/Ignore)
.gitignore based parser implemented in C# according to the [.gitignore spec 2.29.2](https://git-scm.com/docs/gitignore).
The library is tested against real `git status` outputs. The tests use `LibGit2Sharp` for that.
## Installation
Ignore can be installed from NuGet.
```PowerShell
Install-Package Ignore
```
## Usage
```cs
// 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");
```
## Developing
Ignore targets `netstandard2.0` and `net8.0` for the main library and uses `net6.0` and `net8.0` for the unit tests (Xunit).
### Build
From the root directory
```console
dotnet build
```
### Test
From the root directory
```console
dotnet test
```