Skip to content

Commit 051c3ec

Browse files
committed
fixup! Enforce repo.RetrieveStatus() test coverage
1 parent ef3c6b4 commit 051c3ec

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,19 +614,23 @@ public void CanHandleTwoStatusEntryChangesWithTheSamePath()
614614

615615
Commit commit = repo.ObjectDatabase.CreateCommit(Constants.Signature, Constants.Signature, "A symlink", tree, Enumerable.Empty<Commit>(), false);
616616
repo.Refs.UpdateTarget("HEAD", commit.Id.Sha);
617+
618+
// Sets the index to the just created commit
617619
repo.Reset(ResetMode.Mixed);
618620

619621
string parentPath = Path.Combine(repo.Info.WorkingDirectory, "include/Nu");
620622

621623
Touch(parentPath, "Nu.h", "awesome content\n");
622624

623625
RepositoryStatus status = repo.RetrieveStatus(
624-
new StatusOptions{ DetectRenamesInIndex = true, DetectRenamesInWorkDir = true });
626+
new StatusOptions { DetectRenamesInIndex = true, DetectRenamesInWorkDir = true });
625627

626628
Assert.Equal(2, status.Count());
627629

628630
var expected = Path.Combine("include", "Nu", "Nu.h");
629631

632+
// Two different code paths here because both HEAD and the Index contains a symlink
633+
// But we can't trust a Windows filesystem to correctly handle this kind of filemode
630634
if (IsRunningOnUnix())
631635
{
632636
Assert.Equal(expected, status.RenamedInWorkDir.Single().FilePath);
@@ -638,6 +642,16 @@ public void CanHandleTwoStatusEntryChangesWithTheSamePath()
638642
Assert.Equal(Path.Combine("objc", "Nu.h"), status.Missing.Single().FilePath);
639643
}
640644

645+
// Replace the symlink in the index with a plain file
646+
repo.Stage(parentPath);
647+
648+
status = repo.RetrieveStatus(
649+
new StatusOptions { DetectRenamesInIndex = true, DetectRenamesInWorkDir = true });
650+
651+
Assert.Equal(2, status.Count());
652+
653+
Assert.Equal(expected, status.Staged.Single().FilePath);
654+
Assert.Equal(Path.Combine("objc", "Nu.h"), status.Missing.Single().FilePath);
641655
}
642656
}
643657
}

0 commit comments

Comments
 (0)