Skip to content

Commit

Permalink
Remove baseVersionBuildMetaData == null check
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPykavy committed Jan 6, 2023
1 parent 10eecbe commit 4d510b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ public void ChoosesHighestVersionReturnedFromStrategies()
repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(Enumerable.Empty<IBranch>());
var dateTimeOffset = DateTimeOffset.Now;
var versionStrategies = new IVersionStrategy[] { new V1Strategy(DateTimeOffset.Now), new V2Strategy(dateTimeOffset) };
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), Substitute.For<IMainlineVersionCalculator>(),
var mainlineVersionCalculatorMock = Substitute.For<IMainlineVersionCalculator>();
mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any<ICommit?>()).Returns(new SemanticVersionBuildMetaData());
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), mainlineVersionCalculatorMock,
repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock);

// Act
Expand Down Expand Up @@ -342,7 +344,9 @@ public void UsesWhenFromNextBestMatchIfHighestDoesntHaveWhen()
repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(Enumerable.Empty<IBranch>());
var when = DateTimeOffset.Now;
var versionStrategies = new IVersionStrategy[] { new V1Strategy(when), new V2Strategy(null) };
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), Substitute.For<IMainlineVersionCalculator>(),
var mainlineVersionCalculatorMock = Substitute.For<IMainlineVersionCalculator>();
mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any<ICommit?>()).Returns(new SemanticVersionBuildMetaData());
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), mainlineVersionCalculatorMock,
repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock);

// Act
Expand Down Expand Up @@ -371,7 +375,9 @@ public void UsesWhenFromNextBestMatchIfHighestDoesntHaveWhenReversedOrder()
repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(Enumerable.Empty<IBranch>());
var when = DateTimeOffset.Now;
var versionStrategies = new IVersionStrategy[] { new V2Strategy(null), new V1Strategy(when) };
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), Substitute.For<IMainlineVersionCalculator>(),
var mainlineVersionCalculatorMock = Substitute.For<IMainlineVersionCalculator>();
mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any<ICommit?>()).Returns(new SemanticVersionBuildMetaData());
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), mainlineVersionCalculatorMock,
repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock);

// Act
Expand Down Expand Up @@ -401,7 +407,9 @@ public void ShouldNotFilterVersion()
repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(Enumerable.Empty<IBranch>());
var version = new BaseVersion("dummy", false, new SemanticVersion(2), GitToolsTestingExtensions.CreateMockCommit(), null);
var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(version) };
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), Substitute.For<IMainlineVersionCalculator>(),
var mainlineVersionCalculatorMock = Substitute.For<IMainlineVersionCalculator>();
mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any<ICommit?>()).Returns(new SemanticVersionBuildMetaData());
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), mainlineVersionCalculatorMock,
repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock);

// Act
Expand Down Expand Up @@ -431,7 +439,9 @@ public void ShouldFilterVersion()
var higherVersion = new BaseVersion("exclude", false, new SemanticVersion(2), GitToolsTestingExtensions.CreateMockCommit(), null);
var lowerVersion = new BaseVersion("dummy", false, new SemanticVersion(1), GitToolsTestingExtensions.CreateMockCommit(), null);
var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(higherVersion, lowerVersion) };
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), Substitute.For<IMainlineVersionCalculator>(),
var mainlineVersionCalculatorMock = Substitute.For<IMainlineVersionCalculator>();
mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any<ICommit?>()).Returns(new SemanticVersionBuildMetaData());
var unitUnderTest = new NextVersionCalculator(Substitute.For<ILog>(), mainlineVersionCalculatorMock,
repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock);

// Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public virtual NextVersion FindVersion()
{
var baseVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource);

if (baseVersionBuildMetaData == null || baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData?.Sha)
if (baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData?.Sha)
{
semver = nextVersion.IncrementedVersion;
}
Expand Down

0 comments on commit 4d510b2

Please sign in to comment.