private static void AssertMergeMessage(string message, string expectedVersion, IEnumerable <ICommit> parents, Config config = null) { var commit = GitToolsTestingExtensions.CreateMockCommit(); commit.Message.Returns(message); commit.Parents.Returns(parents); var mockBranch = GitToolsTestingExtensions.CreateMockBranch(MainBranch, commit, GitToolsTestingExtensions.CreateMockCommit()); var mockRepository = Substitute.For <IGitRepository>(); mockRepository.Head.Returns(mockBranch); mockRepository.Commits.Returns(mockBranch.Commits); var contextBuilder = new GitVersionContextBuilder() .WithConfig(config ?? new Config()) .WithRepository(mockRepository); contextBuilder.Build(); var strategy = contextBuilder.ServicesProvider.GetServiceForType <IVersionStrategy, MergeMessageVersionStrategy>(); var baseVersion = strategy.GetVersions().SingleOrDefault(); if (expectedVersion == null) { baseVersion.ShouldBe(null); } else { baseVersion.ShouldNotBeNull(); baseVersion.SemanticVersion.ToString().ShouldBe(expectedVersion); } }
private void AssertMergeMessage(string message, string expectedVersion, IList <ICommit> parents, Config config = null) { var commit = new MockCommit { MessageEx = message, ParentsEx = parents }; var contextBuilder = new GitVersionContextBuilder() .WithConfig(config ?? new Config()) .WithRepository(new MockRepository { Head = new MockBranch("master") { commit, new MockCommit() } }); contextBuilder.Build(); var strategy = contextBuilder.ServicesProvider.GetServiceForType <IVersionStrategy, MergeMessageVersionStrategy>(); var baseVersion = strategy.GetVersions().SingleOrDefault(); if (expectedVersion == null) { baseVersion.ShouldBe(null); } else { baseVersion.ShouldNotBeNull(); baseVersion.SemanticVersion.ToString().ShouldBe(expectedVersion); } }
public void ShouldNotAllowIncrementOfVersion() { // When a branch is merged in you want to start building stable packages of that version // So we shouldn't bump the version var mockCommit = GitToolsTestingExtensions.CreateMockCommit(); mockCommit.Message.Returns("Merge branch 'release-0.1.5'"); mockCommit.Parents.Returns(GetParents(true)); var mockBranch = GitToolsTestingExtensions.CreateMockBranch(MainBranch, mockCommit); var branches = Substitute.For <IBranchCollection>(); branches.GetEnumerator().Returns(_ => ((IEnumerable <IBranch>) new[] { mockBranch }).GetEnumerator()); var mockRepository = Substitute.For <IGitRepository>(); mockRepository.Head.Returns(mockBranch); mockRepository.Branches.Returns(branches); mockRepository.Commits.Returns(mockBranch.Commits); var contextBuilder = new GitVersionContextBuilder().WithRepository(mockRepository); contextBuilder.Build(); var strategy = contextBuilder.ServicesProvider.GetServiceForType <IVersionStrategy, MergeMessageVersionStrategy>(); var baseVersion = strategy.GetVersions().Single(); baseVersion.ShouldIncrement.ShouldBe(false); }
public void ReturnsNullWhenNoNextVersionIsInConfig() { var gitVersionContext = contextBuilder.Build(); var baseVersion = strategy.GetVersions(gitVersionContext).SingleOrDefault(); baseVersion.ShouldBe(null); }
public void ReturnsNullWhenNoNextVersionIsInConfig() { var contextBuilder = new GitVersionContextBuilder(); var sut = new ConfigNextVersionBaseVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).SingleOrDefault(); baseVersion.ShouldBe(null); }
public void ReturnsNullWhenNoNextVersionIsInConfig() { var contextBuilder = new GitVersionContextBuilder(); var sut = new ConfigNextVersionBaseVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).SingleOrDefault(); baseVersion.ShouldBe(null); }
private static IBaseVersionCalculator GetBaseVersionCalculator(Action <GitVersionContextBuilder> contextBuilderAction) { var contextBuilder = new GitVersionContextBuilder(); contextBuilderAction.Invoke(contextBuilder); contextBuilder.Build(); contextBuilder.ServicesProvider.ShouldNotBeNull(); return(contextBuilder.ServicesProvider.GetRequiredService <IBaseVersionCalculator>()); }
public void NextVersionCanHavePatch() { var contextBuilder = new GitVersionContextBuilder() .WithConfig(new Config { NextVersion = "2.12.654651698" }); var sut = new ConfigNextVersionBaseVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).Single(); baseVersion.SemanticVersion.ToString().ShouldBe("2.12.654651698"); }
public void NextVersionCanHaveEnormousMinorVersion() { var contextBuilder = new GitVersionContextBuilder() .WithConfig(new Config { NextVersion = "2.118998723" }); var sut = new ConfigNextVersionBaseVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).Single(); baseVersion.SemanticVersion.ToString().ShouldBe("2.118998723.0"); }
public void NextVersionCanHavePatch() { var contextBuilder = new GitVersionContextBuilder() .WithConfig(new Config { NextVersion = "2.12.654651698" }); var sut = new ConfigNextVersionBaseVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).Single(); baseVersion.SemanticVersion.ToString().ShouldBe("2.12.654651698"); }
public void NextVersionCanHaveEnormousMinorVersion() { var contextBuilder = new GitVersionContextBuilder() .WithConfig(new Config { NextVersion = "2.118998723" }); var sut = new ConfigNextVersionBaseVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).Single(); baseVersion.SemanticVersion.ToString().ShouldBe("2.118998723.0"); }
public void NextVersionCanBeInteger() { var contextBuilder = new GitVersionContextBuilder() .WithConfig(new Config { NextVersion = "2" }); var sut = new ConfigNextVersionVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).Single(); baseVersion.SemanticVersion.ToString().ShouldBe("2.0.0"); }
public void ShouldNotBeIncremented() { var contextBuilder = new GitVersionContextBuilder() .WithConfig(new Config { NextVersion = "1.0.0" }); var sut = new ConfigNextVersionBaseVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).Single(); baseVersion.ShouldIncrement.ShouldBe(false); baseVersion.SemanticVersion.ToString().ShouldBe("1.0.0"); }
private static BaseVersion GetBaseVersion(Config config = null) { var contextBuilder = new GitVersionContextBuilder(); if (config != null) { contextBuilder = contextBuilder.WithConfig(config); } contextBuilder.Build(); var strategy = contextBuilder.ServicesProvider.GetServiceForType <IVersionStrategy, ConfigNextVersionVersionStrategy>(); return(strategy.GetVersions().SingleOrDefault()); }
public void ShouldNotBeIncremented() { var contextBuilder = new GitVersionContextBuilder() .WithConfig(new Config { NextVersion = "1.0.0" }); var sut = new ConfigNextVersionBaseVersionStrategy(); var baseVersion = sut.GetVersions(contextBuilder.Build()).Single(); baseVersion.ShouldIncrement.ShouldBe(false); baseVersion.SemanticVersion.ToString().ShouldBe("1.0.0"); }
public void ShouldNotAllowIncrementOfVersion() { // When a branch is merged in you want to start building stable packages of that version // So we shouldn't bump the version var contextBuilder = new GitVersionContextBuilder().WithRepository(new MockRepository { Head = new MockBranch("master") { new MockCommit { MessageEx = "Merge branch 'release-0.1.5'", ParentsEx = GetParents(true) } } }); contextBuilder.Build(); var strategy = contextBuilder.ServicesProvider.GetServiceForType <IVersionStrategy, MergeMessageVersionStrategy>(); var baseVersion = strategy.GetVersions().Single(); baseVersion.ShouldIncrement.ShouldBe(false); }