Skip to content

Commit c9dae06

Browse files
committed
Enhance .gitignore capabilities test coverage
1 parent 7a31788 commit c9dae06

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

LibGit2Sharp.Tests/IgnoreFixture.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,32 @@ public void CanCheckIfAPathIsIgnoredUsingThePreferedPlatformDirectorySeparatorCh
8181
Assert.True(repo.Ignore.IsPathIgnored(string.Format(@"NewFolder{0}NewFolder{0}File.txt", Path.DirectorySeparatorChar)));
8282
}
8383
}
84+
85+
[Fact]
86+
public void HonorThePlatformPathSeparatorCharInTheGitIgnoreFile()
87+
{
88+
string path = InitNewRepository();
89+
using (var repo = new Repository(path))
90+
{
91+
Touch(repo.Info.WorkingDirectory, ".gitignore", string.Format("{0}fixes{1}Fixes.zip{1}",
92+
Path.DirectorySeparatorChar, Environment.NewLine));
93+
Touch(repo.Info.WorkingDirectory, "fixes/one", "one{1}");
94+
Touch(repo.Info.WorkingDirectory, "fixes/two", "two{1}");
95+
Touch(repo.Info.WorkingDirectory, "Fixes.zip", "three{1}");
96+
Touch(repo.Info.WorkingDirectory, "Hello.txt", "world{1}");
97+
98+
Assert.False(repo.Ignore.IsPathIgnored("Hello.txt"));
99+
Assert.True(repo.Ignore.IsPathIgnored("fixes"));
100+
Assert.True(repo.Ignore.IsPathIgnored(string.Format(@"fixes{0}one", Path.DirectorySeparatorChar)));
101+
Assert.True(repo.Ignore.IsPathIgnored("Fixes.zip"));
102+
103+
var status = repo.RetrieveStatus();
104+
105+
Assert.Equal(new[] { "Fixes.zip", string.Format("fixes{0}", Path.DirectorySeparatorChar) },
106+
status.Ignored.Select(se => se.FilePath));
107+
Assert.Equal(new[] { ".gitignore", "Hello.txt" },
108+
status.Untracked.Select(se => se.FilePath));
109+
}
110+
}
84111
}
85112
}

0 commit comments

Comments
 (0)