8000 Enhance Index.[Stage|Unstage]() test coverage · rlazev/libgit2sharp@474cc1c · GitHub
[go: up one dir, main page]

Skip to content

Commit 474cc1c

Browse files
committed
Enhance Index.[Stage|Unstage]() test coverage
1 parent e8b0741 commit 474cc1c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

LibGit2Sharp.Tests/IndexFixture.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,29 @@ public void CanStageANewFileWithARelativePathContainingNativeDirectorySeparatorC
264264
}
265265
}
266266

267+
[Fact]
268+
public void CanStageAndUnstageAnIgnoredFile()
269+
{
270+
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
271+
using (var repo = new Repository(path.RepositoryPath))
272+
{
273+
string gitignorePath = Path.Combine(repo.Info.WorkingDirectory, ".gitignore");
274+
File.WriteAllText(gitignorePath, "*.ign" + Environment.NewLine);
275+
276+
const string relativePath = "Champa.ign";
277+
string gitignoredFile = Path.Combine(repo.Info.WorkingDirectory, relativePath);
278+
File.WriteAllText(gitignoredFile, "On stage!" + Environment.NewLine);
279+
280+
Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath));
281+
282+
repo.Index.Stage(relativePath);
283+
Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(relativePath));
284+
285+
repo.Index.Unstage(relativePath);
286+
Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath));
287+
}
288+
}
289+
267290
[Fact]
268291
public void StagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows()
269292
{

0 commit comments

Comments
 (0)
0