Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ You may want to statically upload the contents of a folder. For example maybe th

**Caveat**: To ignore files the `.kickflipignore` file must be present IN the folder.

### .kickflipignore

One glob per line. A line starting with `!` re-includes files another pattern ignored, e.g. ignore all dotfiles but still deploy `.htaccess`:

.*
!.htaccess

Unlike `.gitignore`, order doesn't matter: a `!` pattern always wins.

### Pull request comments

Kickflip can post a summary of the changes that will be deployed as a comment on a pull request:
Expand Down
14 changes: 14 additions & 0 deletions src/kickflip.Tests/IgnoreServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ public void IsIgnored_HonoursPatternsInIgnoreFile()
Assert.False(service.IsIgnored("index.html"));
}

[Fact]
public void IsIgnored_NegatedPatternReincludesFile()
{
using var directory = new TempDirectory();
directory.WriteFile(".kickflipignore", ".*\n!.htaccess\n!.user.ini");
var service = new IgnoreService(directory.Path);

Assert.True(service.IsIgnored(".env"));
Assert.False(service.IsIgnored(".htaccess"));
Assert.False(service.IsIgnored(".user.ini"));
Assert.False(service.IsIgnored("index.php"));
Assert.True(service.IsIgnored(".kickflipignore"));
}

[Fact]
public void IsIgnored_AlwaysIgnoresTheIgnoreFileItself()
{
Expand Down
14 changes: 12 additions & 2 deletions src/kickflip/Services/IgnoreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@ public IgnoreService(string localPath)
return;
}

var ignorePatterns = File.ReadAllLines(ignoreFile);
_matcher.AddIncludePatterns(ignorePatterns);
foreach (var pattern in File.ReadAllLines(ignoreFile))
{
// "!pattern" re-includes files an earlier pattern ignored; unlike .gitignore, order doesn't matter
if (pattern.StartsWith('!'))
{
_matcher.AddExclude(pattern[1..]);
}
else
{
_matcher.AddInclude(pattern);
}
}
}

public bool IsIgnored(string path)
Expand Down
Loading