Skip to content

Commit 74e617b

Browse files
committed
Add short commit id test
1 parent 7685c32 commit 74e617b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/NerdBank.GitVersioning.Tests/VersionOracleTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,18 @@ public void GetVersionHeight_ProjectDirectoryIsMoved()
794794
Assert.Equal(1, this.GetVersionHeight("new-project-dir"));
795795
}
796796

797+
[Fact]
798+
public void OptimallyShortCommitId()
799+
{
800+
this.WriteVersionFile(new VersionOptions { Version = SemanticVersion.Parse("1.2"), GitCommitIdShortAutoMinimum = 4 });
801+
this.InitializeSourceControl();
802+
this.AddCommits(1);
803+
var oracle = new VersionOracle(this.Context);
804+
805+
// I'm not sure why libgit2 returns 7 as the minimum length when clearly a two commit repo would need fewer.
806+
Assert.Equal(7, oracle.GitCommitIdShort.Length);
807+
}
808+
797809
[Fact(Skip = "Slow test")]
798810
public void GetVersionHeight_VeryLongHistory()
799811
{

0 commit comments

Comments
 (0)