Skip to content

Commit

Permalink
Merge pull request #3927 from nils-a/feature/GH-3916
Browse files Browse the repository at this point in the history
(#3916) added ShortSha to the output
  • Loading branch information
nils-a authored Jul 29, 2022
2 parents 8e23c23 + 4b0d035 commit c3f7415
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public void Should_Tolerate_Bad_Json_Set()
InformationalVersion = "0.1.1+Branch.master.Sha.f2467748c78b3c8b37972ad0b30df2e15dfbf2cb",
BranchName = "master",
Sha = "f2467748c78b3c8b37972ad0b30df2e15dfbf2cb",
ShortSha = "f2467748",
NuGetVersionV2 = "0.1.1",
NuGetVersion = "0.1.1",
CommitsSinceVersionSource = null,
Expand Down Expand Up @@ -315,6 +316,7 @@ public void Should_Tolerate_Bad_Json_Set()
" \"InformationalVersion\":\"0.1.1+Branch.master.Sha.f2467748c78b3c8b37972ad0b30df2e15dfbf2cb\",",
" \"BranchName\":\"master\",",
" \"Sha\":\"f2467748c78b3c8b37972ad0b30df2e15dfbf2cb\",",
" \"ShortSha\":\"f2467748\",",
" \"NuGetVersionV2\":\"0.1.1\",",
" \"NuGetVersion\":\"0.1.1\",",
" \"CommitsSinceVersionSource\":\"\",",
Expand Down Expand Up @@ -348,6 +350,7 @@ public void Should_Tolerate_Bad_Json_Set()
Assert.Equal(expect.InformationalVersion, result.InformationalVersion);
Assert.Equal(expect.BranchName, result.BranchName);
Assert.Equal(expect.Sha, result.Sha);
Assert.Equal(expect.ShortSha, result.ShortSha);
Assert.Equal(expect.NuGetVersionV2, result.NuGetVersionV2);
Assert.Equal(expect.NuGetVersion, result.NuGetVersion);
Assert.Equal(expect.CommitsSinceVersionSource, result.CommitsSinceVersionSource);
Expand Down
5 changes: 5 additions & 0 deletions src/Cake.Common/Tools/GitVersion/GitVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public sealed class GitVersion
/// </summary>
public string Sha { get; set; }

/// <summary>
/// Gets or sets the shortened Git SHA.
/// </summary>
public string ShortSha { get; set; }

/// <summary>
/// Gets or sets the NuGet version for v2.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions src/Cake.Common/Tools/GitVersion/GitVersionInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ public string Sha
set => GitVersion.Sha = value;
}

[DataMember]
public string ShortSha
{
get => GitVersion.ShortSha;
set => GitVersion.ShortSha = value;
}

[DataMember]
public string NuGetVersionV2
{
Expand Down

0 comments on commit c3f7415

Please sign in to comment.