Skip to content

Commit

Permalink
Introduce a baseVersion variable to shorten the property call
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPykavy committed Oct 29, 2022
1 parent f261b61 commit 059375f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,25 @@ public virtual NextVersion FindVersion()
}

var nextVersion = Calculate(Context.CurrentBranch, Context.Configuration);
var preReleaseTagName = nextVersion.Configuration.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, nextVersion.BaseVersion.BranchNameOverride);
var baseVersion = nextVersion.BaseVersion;
var preReleaseTagName = nextVersion.Configuration.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, baseVersion.BranchNameOverride);

SemanticVersion semver;
if (Context.Configuration.VersioningMode == VersioningMode.Mainline)
{
semver = this.mainlineVersionCalculator.FindMainlineModeVersion(nextVersion.BaseVersion);
semver = this.mainlineVersionCalculator.FindMainlineModeVersion(baseVersion);
}
else
{
var baseVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(nextVersion.BaseVersion.BaseVersionSource);
var baseVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource);

if (baseVersionBuildMetaData == null || baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData?.Sha)
{
semver = nextVersion.IncrementedVersion;
}
else
{
semver = nextVersion.BaseVersion.SemanticVersion;
semver = baseVersion.SemanticVersion;
}

semver.BuildMetaData = baseVersionBuildMetaData;
Expand Down Expand Up @@ -106,7 +107,7 @@ public virtual NextVersion FindVersion()
semver.PreReleaseTag = new SemanticVersionPreReleaseTag(preReleaseTagName, number);
}

return new(semver, nextVersion.BaseVersion, new(nextVersion.Branch, nextVersion.Configuration));
return new(semver, baseVersion, new(nextVersion.Branch, nextVersion.Configuration));
}

private static void EnsureHeadIsNotDetached(GitVersionContext context)
Expand Down

0 comments on commit 059375f

Please sign in to comment.