Skip to content

Commit

Permalink
Fix compile suggestion in NextVersionCalculator.
Browse files Browse the repository at this point in the history
  • Loading branch information
HHobeck authored and arturcic committed Oct 4, 2022
1 parent 8455426 commit c8e26ed
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public class NextVersionCalculator : INextVersionCalculator
private readonly IRepositoryStore repositoryStore;
private readonly IIncrementStrategyFinder incrementStrategyFinder;
private readonly Lazy<GitVersionContext> versionContext;
private GitVersionContext context => this.versionContext.Value;

private GitVersionContext Context => this.versionContext.Value;

public NextVersionCalculator(
ILog log,
Expand All @@ -34,32 +35,32 @@ public NextVersionCalculator(

public NextVersion FindVersion()
{
this.log.Info($"Running against branch: {context.CurrentBranch} ({context.CurrentCommit?.ToString() ?? "-"})");
if (context.IsCurrentCommitTagged)
this.log.Info($"Running against branch: {Context.CurrentBranch} ({Context.CurrentCommit?.ToString() ?? "-"})");
if (Context.IsCurrentCommitTagged)
{
this.log.Info($"Current commit is tagged with version {context.CurrentCommitTaggedVersion}, " + "version calculation is for metadata only.");
this.log.Info($"Current commit is tagged with version {Context.CurrentCommitTaggedVersion}, " + "version calculation is for metadata only.");
}
else
{
EnsureHeadIsNotDetached(context);
EnsureHeadIsNotDetached(Context);
}

SemanticVersion? taggedSemanticVersion = null;

if (context.IsCurrentCommitTagged)
if (Context.IsCurrentCommitTagged)
{
// Will always be 0, don't bother with the +0 on tags
var semanticVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(context.CurrentCommit);
var semanticVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(Context.CurrentCommit);
semanticVersionBuildMetaData.CommitsSinceTag = null;

var semanticVersion = new SemanticVersion(context.CurrentCommitTaggedVersion) { BuildMetaData = semanticVersionBuildMetaData };
var semanticVersion = new SemanticVersion(Context.CurrentCommitTaggedVersion) { BuildMetaData = semanticVersionBuildMetaData };
taggedSemanticVersion = semanticVersion;
}

var (baseVersion, configuration) = this.baseVersionCalculator.GetBaseVersion();
baseVersion.SemanticVersion.BuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource);
SemanticVersion semver;
if (context.FullConfiguration.VersioningMode == VersioningMode.Mainline)
if (Context.FullConfiguration.VersioningMode == VersioningMode.Mainline)
{
semver = this.mainlineVersionCalculator.FindMainlineModeVersion(baseVersion);
}
Expand Down Expand Up @@ -106,19 +107,19 @@ public NextVersion FindVersion()
private SemanticVersion PerformIncrement(BaseVersion baseVersion, EffectiveConfiguration configuration)
{
var semver = baseVersion.SemanticVersion;
var increment = this.incrementStrategyFinder.DetermineIncrementedField(context, baseVersion, configuration);
var increment = this.incrementStrategyFinder.DetermineIncrementedField(Context, baseVersion, configuration);
semver = semver.IncrementVersion(increment);
return semver;
}

private void UpdatePreReleaseTag(EffectiveConfiguration configuration, SemanticVersion semanticVersion, string? branchNameOverride)
{
var tagToUse = configuration.GetBranchSpecificTag(this.log, context.CurrentBranch.Name.Friendly, branchNameOverride);
var tagToUse = configuration.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, branchNameOverride);

long? number = null;

var lastTag = this.repositoryStore
.GetVersionTagsOnBranch(context.CurrentBranch, context.FullConfiguration.TagPrefix)
.GetVersionTagsOnBranch(Context.CurrentBranch, Context.FullConfiguration.TagPrefix)
.FirstOrDefault(v => v.PreReleaseTag?.Name?.IsEquivalentTo(tagToUse) == true);

if (lastTag != null && MajorMinorPatchEqual(lastTag, semanticVersion) && lastTag.PreReleaseTag?.HasTag() == true)
Expand Down

0 comments on commit c8e26ed

Please sign in to comment.