public void PreReleaseNumberShouldBeScopeToPreReleaseLabelInContinuousDelivery()
        {
            var config = new Config
            {
                VersioningMode = VersioningMode.ContinuousDelivery,
                Branches = new Dictionary<string, BranchConfig>
                {
                    {
                        "master", new BranchConfig()
                        {
                            Tag = "beta"
                        }
                    },
                }
            };

            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.Repository.MakeACommit();

                fixture.Repository.CreateBranch("feature/test");
                fixture.Repository.Checkout("feature/test");
                fixture.Repository.MakeATaggedCommit("0.1.0-test.1");
                fixture.Repository.MakeACommit();

                fixture.AssertFullSemver(config, "0.1.0-test.2+2");

                fixture.Repository.Checkout("master");
                fixture.Repository.Merge(fixture.Repository.FindBranch("feature/test"), Generate.SignatureNow());

                fixture.AssertFullSemver(config, "0.1.0-beta.1+2");
            }
        }
Пример #2
0
        public void AllowNotHavingMaster()
        {
            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.Repository.MakeACommit();
                fixture.Repository.MakeATaggedCommit("1.0.0");
                fixture.Repository.MakeACommit();
                fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
                fixture.Repository.Branches.Remove(fixture.Repository.Branches["master"]);

                fixture.AssertFullSemver("1.1.0-unstable.1");
            }
        }
        public void CanTakeVersionFromBranchName(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).SingleOrDefault();

                if (expectedBaseVersion == null)
                    baseVersion.ShouldBe(null);
                else
                    baseVersion.SemanticVersion.ToString().ShouldBe(expectedBaseVersion);
            }
        }
Пример #4
0
        public void CanInheritIncrement(IncrementStrategy increment, IncrementStrategy? alternateExpected)
        {
            // Dummy branch name to make sure that no default config exists.
            const string dummyBranchName = "dummy";

            var config = new Config
            {
                Increment = increment
            };
            ConfigurationProvider.ApplyDefaultsTo(config);

            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.MakeACommit();
                fixture.BranchTo(dummyBranchName);
                fixture.MakeACommit();

                var context = new GitVersionContext(fixture.Repository, fixture.Repository.Branches[dummyBranchName], config);
                context.Configuration.Increment.ShouldBe(alternateExpected ?? increment);
            }
        }
Пример #5
0
        public void AllowHavingMainInsteadOfMaster()
        {
            var config = new Config();
            config.Branches.Add("main", new BranchConfig
            {
                VersioningMode = VersioningMode.ContinuousDelivery,
                Tag = "useBranchName",
                Increment = IncrementStrategy.Patch,
                PreventIncrementOfMergedBranchVersion = true,
                TrackMergeTarget = false
            });

            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.Repository.MakeACommit();
                fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
                fixture.Repository.Checkout(fixture.Repository.CreateBranch("main"));
                fixture.Repository.Branches.Remove(fixture.Repository.Branches["master"]);

                fixture.AssertFullSemver(config, "0.1.0+0");
            }
        }
Пример #6
0
        public void CanFindParentBranchForInheritingIncrementStrategy()
        {
            var config = new Config
            {
                Branches =
                {
                    { "develop", new BranchConfig { Increment = IncrementStrategy.Major} },
                    { "feature", new BranchConfig { Increment = IncrementStrategy.Inherit} }
                }
            }.ApplyDefaults();

            using (var repo = new EmptyRepositoryFixture())
            {
                repo.Repository.MakeACommit();
                Commands.Checkout(repo.Repository, repo.Repository.CreateBranch("develop"));
                repo.Repository.MakeACommit();
                var featureBranch = repo.Repository.CreateBranch("feature/foo");
                Commands.Checkout(repo.Repository, featureBranch);
                repo.Repository.MakeACommit();

                var context = new GitVersionContext(repo.Repository, config);
                context.Configuration.Increment.ShouldBe(IncrementStrategy.Major);
            }
        }
        public void PreReleaseTagCanUseBranchName()
        {
            var config = new Config
            {
                NextVersion = "1.0.0",
                Branches = new Dictionary<string, BranchConfig>
                {
                    {
                        "custom", new BranchConfig
                        {
                            Regex = "custom/",
                            Tag = "useBranchName"
                        }
                    }
                }
            };

            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.MakeACommit();
                fixture.BranchTo("develop");
                fixture.MakeACommit();
                fixture.BranchTo("custom/foo");
                fixture.MakeACommit();

                fixture.AssertFullSemver(config, "1.0.0-foo.1+2");
            }
        }