Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#3916) added ShortSha to the output #3927

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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