Skip to content

Commit c38e696

Browse files
committed
Update AssemblyInformationalVersion and tests
1 parent 77b6fa4 commit c38e696

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

LibGit2Sharp.Tests/GlobalSettingsFixture.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ public void CanGetMinimumCompiledInFeatures()
1919
public void CanRetrieveValidVersionString()
2020
{
2121
// Version string format is:
22-
// Major.Minor.Patch[-somePreleaseTag]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|x64 - features)
22+
// Major.Minor.Patch[-somePreleaseTag]-libgit2_abbrev_hash (x86|x64 - features)
2323
// Example output:
24-
// "0.17.0[-pre20170914123547]-deadcafe-06d772d (x86 - Threads, Https)"
24+
// "0.17.0[-beta]+gdeadcafeee.LibGit2-06d772d (x86 - Threads, Https)"
2525

2626
string versionInfo = GlobalSettings.Version.ToString();
2727

2828
// The GlobalSettings.Version returned string should contain :
29-
// version: '0.17.0[-somePreleaseTag][+gSomeGitCommit]' LibGit2Sharp version number.
30-
// git2SharpHash:'unknown' ( when compiled from source ) else LibGit2Sharp library hash.
29+
// version: '0.17.0[-somePreleaseTag]+[gSomeGitCommit.]LibGit2-06d772d' LibGit2Sharp version number.
3130
// git2hash: '06d772d' LibGit2 library hash.
3231
// arch: 'x86' or 'x64' LibGit2 target.
3332
// git2Features: 'Threads, Ssh' LibGit2 features compiled with.
34-
string regex = @"^(?<version>\d+\.\d+\.\d+(-\w+)?(\+g[a-f0-9]{10})?)-(?<git2SharpHash>\w+)-(?<git2Hash>\w+) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$";
33+
string regex = @"^(?<version>\d+\.\d+\.\d+(-\w+)?\+(g(?<git2SharpHash>[a-f0-9]{10})\.)?LibGit2-[a-f0-9]{7}) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$";
3534

3635
Assert.NotNull(versionInfo);
3736

3837
Match regexResult = Regex.Match(versionInfo, regex);
3938

4039
Assert.True(regexResult.Success, "The following version string format is enforced:" +
41-
"Major.Minor.Patch[-somePreleaseTag][+gSomeGitCommit]-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|x64 - features)");
40+
"Major.Minor.Patch[-somePreleaseTag]+[gSomeGitCommit].LibGit2-abbrev_hash (x86|x64 - features). " +
41+
"But found \"" + versionInfo + "\" instead.");
4242
}
4343

4444
[Fact]

LibGit2Sharp/CodeGenerator.targets

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ namespace LibGit2Sharp.Core
6161
</ItemGroup>
6262
</Target>
6363

64+
<Target Name="AddNativeDllCommitShaToBuildMetadata"
65+
BeforeTargets="GetBuildVersion"
66+
Condition=" '$(IsCrossTargetingBuild)' != 'true' ">
67+
<ReadLinesFromFile File="@(EmbeddedResource)"
68+
Condition=" '%(Filename)%(Extension)' == 'libgit2_hash.txt' ">
69+
<Output TaskParameter="Lines" PropertyName="libgit2hash" />
70+
</ReadLinesFromFile>
71+
72+
<ItemGroup>
73+
<BuildMetadata Include="LibGit2-$(libgit2hash.Substring(0,7))" />
74+
</ItemGroup>
75+
</Target>
76+
6477
<Target Name="GenerateCommitIdVersion"
6578
DependsOnTargets="GetBuildVersion">
6679
<WriteLinesToFile File="$(CommitIdVersionPath)"

LibGit2Sharp/Version.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ private string RetrieveVersion()
8080
string features = Features.ToString();
8181

8282
return string.Format(CultureInfo.InvariantCulture,
83-
"{0}-{1}-{2} ({3} - {4})",
83+
"{0} ({1} - {2})",
8484
InformationalVersion,
85-
LibGit2SharpCommitSha,
86-
LibGit2CommitSha,
8785
Platform.ProcessorArchitecture,
8886
features);
8987
}

0 commit comments

Comments
 (0)