Ejemplo n.º 1
0
        public void ShouldNotTakeVersionFromNameOfNonReleaseBranch(string branchName)
        {
            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.Repository.MakeACommit();
                var branch = fixture.Repository.CreateBranch(branchName);
                var sut    = new VersionInBranchNameBaseVersionStrategy();

                var gitVersionContext = new GitVersionContext(fixture.Repository, branch, new Config().ApplyDefaults());
                var baseVersions      = sut.GetVersions(gitVersionContext);

                baseVersions.ShouldBeEmpty();
            }
        }
Ejemplo n.º 2
0
        public void CanTakeVersionFromNameOfReleaseBranch(string branchName, string expectedBaseVersion)
        {
            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.Repository.MakeACommit();
                var branch = fixture.Repository.CreateBranch(branchName);
                var sut    = new VersionInBranchNameBaseVersionStrategy();

                var gitVersionContext = new GitVersionContext(fixture.Repository, branch, new Config().ApplyDefaults());
                var baseVersion       = sut.GetVersions(gitVersionContext).Single();

                baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
            }
        }
Ejemplo n.º 3
0
        public void CanTakeVersionFromNameOfRemoteReleaseBranch(string branchName, string expectedBaseVersion)
        {
            using (var fixture = new RemoteRepositoryFixture())
            {
                var branch = fixture.Repository.CreateBranch(branchName);
                Commands.Checkout(fixture.Repository, branch);
                fixture.MakeACommit();

                Commands.Fetch((Repository)fixture.LocalRepositoryFixture.Repository, fixture.LocalRepositoryFixture.Repository.Network.Remotes.First().Name, new string[0], new FetchOptions(), null);
                fixture.LocalRepositoryFixture.Checkout($"origin/{branchName}");

                var sut = new VersionInBranchNameBaseVersionStrategy();
                var gitVersionContext = new GitVersionContext(fixture.Repository, branch, new Config().ApplyDefaults());
                var baseVersion       = sut.GetVersions(gitVersionContext).Single();

                baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
            }
        }
Ejemplo n.º 4
0
        public void CanTakeVersionFromNameOfConfiguredReleaseBranch(string branchName, string expectedBaseVersion)
        {
            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.Repository.MakeACommit();
                var branch        = fixture.Repository.CreateBranch(branchName);
                var sut           = new VersionInBranchNameBaseVersionStrategy();
                var branchConfigs = new Dictionary <string, BranchConfig> {
                    { "support", new BranchConfig {
                          IsReleaseBranch = true
                      } }
                };
                var config = new Config {
                    Branches = branchConfigs
                }.ApplyDefaults();

                var gitVersionContext = new GitVersionContext(fixture.Repository, branch, config);
                var baseVersion       = sut.GetVersions(gitVersionContext).Single();

                baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
            }
        }