Skip to content

Commit 4130b94

Browse files
committed
Add test coverage demonstrating the handling of .gitgnore file
1 parent 9e7bd44 commit 4130b94

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.IO;
1+
using System;
2+
using System.IO;
23
using System.Linq;
34
using LibGit2Sharp.Tests.TestHelpers;
45
using NUnit.Framework;
@@ -125,5 +126,27 @@ public void RetrievingTheStatusOfARepositoryReturnNativeFilePaths()
125126
repoStatus.Added.Single().ShouldEqual(statusEntry.FilePath);
126127
}
127128
}
129+
130+
[Test]
131+
public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
132+
{
133+
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
134+
using (var repo = new Repository(path.RepositoryPath))
135+
{
136+
string relativePath = Path.Combine("1", "look-ma.txt");
137+
string fullFilePath = Path.Combine(repo.Info.WorkingDirectory, relativePath);
138+
File.WriteAllText(fullFilePath, "I'm going to be ignored!");
139+
140+
RepositoryStatus status = repo.Index.RetrieveStatus();
141+
142+
CollectionAssert.AreEqual(new[]{relativePath, "new_untracked_file.txt"}, status.Untracked);
143+
144+
string gitignorePath = Path.Combine(repo.Info.WorkingDirectory, ".gitignore");
145+
File.WriteAllText(gitignorePath, "*.txt" + Environment.NewLine);
146+
147+
RepositoryStatus newStatus = repo.Index.RetrieveStatus();
148+
newStatus.Untracked.Single().ShouldEqual(".gitignore");
149+
}
150+
}
128151
}
129152
}

0 commit comments

Comments
 (0)