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

Remove g prefix in commit IDs #264

Merged
merged 1 commit into from
Dec 8, 2018
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
10 changes: 5 additions & 5 deletions src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public async Task GetBuildVersion_In_Git_But_Head_Lacks_VersionFile()
Assumes.True(repo.Index[VersionFile.JsonFileName] == null);
var buildResult = await this.BuildAsync();
Assert.Equal("3.4.0." + repo.Head.Commits.First().GetIdAsVersion().Revision, buildResult.BuildVersion);
Assert.Equal("3.4.0+g" + repo.Head.Commits.First().Id.Sha.Substring(0, 10), buildResult.AssemblyInformationalVersion);
Assert.Equal("3.4.0+" + repo.Head.Commits.First().Id.Sha.Substring(0, 10), buildResult.AssemblyInformationalVersion);
}

[Fact]
Expand All @@ -201,7 +201,7 @@ public async Task GetBuildVersion_In_Git_No_VersionFile_At_All()
repo.Commit("empty", this.Signer, this.Signer, new CommitOptions { AllowEmptyCommit = true });
var buildResult = await this.BuildAsync();
Assert.Equal("0.0.1." + repo.Head.Commits.First().GetIdAsVersion().Revision, buildResult.BuildVersion);
Assert.Equal("0.0.1+g" + repo.Head.Commits.First().Id.Sha.Substring(0, 10), buildResult.AssemblyInformationalVersion);
Assert.Equal("0.0.1+" + repo.Head.Commits.First().Id.Sha.Substring(0, 10), buildResult.AssemblyInformationalVersion);
}

[Fact]
Expand Down Expand Up @@ -915,7 +915,7 @@ private void AssertStandardProperties(VersionOptions versionOptions, BuildResult
Version assemblyVersion = GetExpectedAssemblyVersion(versionOptions, version);
var additionalBuildMetadata = from item in buildResult.BuildResult.ProjectStateAfterBuild.GetItems("BuildMetadata")
select item.EvaluatedInclude;
var expectedBuildMetadata = $"+g{commitIdShort}";
var expectedBuildMetadata = $"+{commitIdShort}";
if (additionalBuildMetadata.Any())
{
expectedBuildMetadata += "." + string.Join(".", additionalBuildMetadata);
Expand Down Expand Up @@ -944,7 +944,7 @@ private void AssertStandardProperties(VersionOptions versionOptions, BuildResult

// NuGet is now SemVer 2.0 and will pass additional build metadata if provided
bool semVer2 = versionOptions?.NuGetPackageVersionOrDefault.SemVer == 2;
string pkgVersionSuffix = buildResult.PublicRelease ? string.Empty : $"-g{commitIdShort}";
string pkgVersionSuffix = buildResult.PublicRelease ? string.Empty : $"-{commitIdShort}";
if (semVer2)
{
pkgVersionSuffix += expectedBuildMetadataWithoutCommitId;
Expand All @@ -965,7 +965,7 @@ private void AssertStandardProperties(VersionOptions versionOptions, BuildResult
Assert.Equal(expectedVersion, buildNumberSemVer.Version);
Assert.Equal(buildResult.PrereleaseVersion, buildNumberSemVer.Prerelease);
string expectedBuildNumberMetadata = hasCommitData && commitIdOptions.WhereOrDefault == VersionOptions.CloudBuildNumberCommitWhere.BuildMetadata
? $"+g{commitIdShort}"
? $"+{commitIdShort}"
: string.Empty;
if (additionalBuildMetadata.Any())
{
Expand Down
4 changes: 2 additions & 2 deletions src/NerdBank.GitVersioning.Tests/VersionOracleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void DefaultNuGetPackageVersionIsSemVer1NonPublicRelease()
this.InitializeSourceControl();
var oracle = VersionOracle.Create(this.RepoPath);
oracle.PublicRelease = false;
Assert.Equal($"7.8.9-foo-25-g{this.CommitIdShort}", oracle.NuGetPackageVersion);
Assert.Equal($"7.8.9-foo-25-{this.CommitIdShort}", oracle.NuGetPackageVersion);
}

[Fact]
Expand Down Expand Up @@ -240,7 +240,7 @@ public void CanSetSemVer2ForNuGetPackageVersionNonPublicRelease()
this.InitializeSourceControl();
var oracle = VersionOracle.Create(this.RepoPath);
oracle.PublicRelease = false;
Assert.Equal($"7.8.9-foo.25.g{this.CommitIdShort}", oracle.NuGetPackageVersion);
Assert.Equal($"7.8.9-foo.25.{this.CommitIdShort}", oracle.NuGetPackageVersion);
}

[Fact]
Expand Down
6 changes: 3 additions & 3 deletions src/NerdBank.GitVersioning/VersionOracle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public IEnumerable<string> BuildMetadataWithCommitId
{
if (!string.IsNullOrEmpty(this.GitCommitId))
{
yield return $"g{this.GitCommitId.Substring(0, 10)}";
yield return this.GitCommitId.Substring(0, 10);
}

foreach (string identifier in this.BuildMetadata)
Expand Down Expand Up @@ -362,7 +362,7 @@ public IDictionary<string, string> CloudBuildVersionVars
public int SemVer1NumericIdentifierPadding => this.VersionOptions?.SemVer1NumericIdentifierPaddingOrDefault ?? 4;

private string SemVer1BuildMetadata =>
this.PublicRelease ? string.Empty : $"-g{this.GitCommitIdShort}";
this.PublicRelease ? string.Empty : $"-{this.GitCommitIdShort}";

/// <summary>
/// Gets the build metadata that is appropriate for SemVer2 use.
Expand All @@ -377,7 +377,7 @@ public IDictionary<string, string> CloudBuildVersionVars

private string PrereleaseVersionSemVer1 => MakePrereleaseSemVer1Compliant(this.PrereleaseVersion, this.SemVer1NumericIdentifierPadding);

private string GitCommitIdShortForNonPublicPrereleaseTag => (string.IsNullOrEmpty(this.PrereleaseVersion) ? "-" : ".") + $"g{this.GitCommitIdShort}";
private string GitCommitIdShortForNonPublicPrereleaseTag => (string.IsNullOrEmpty(this.PrereleaseVersion) ? "-" : ".") + this.GitCommitIdShort;

private VersionOptions.CloudBuildNumberOptions CloudBuildNumberOptions { get; }

Expand Down