Exemplo n.º 1
0
    public void NoMergeBacksToDevelopInCaseThereAreChangesInReleaseBranch()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeACommit();
            fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
            fixture.Repository.MakeCommits(3);
            var releaseBranch = fixture.Repository.CreateBranch("release/1.0.0");
            fixture.Repository.Checkout(releaseBranch);
            fixture.Repository.MakeACommit();

            // Merge to master
            fixture.Repository.Checkout("master");
            fixture.Repository.MergeNoFF("release/1.0.0");
            fixture.Repository.ApplyTag("1.0.0");

            // Merge to develop
            fixture.Repository.Checkout("develop");
            fixture.Repository.MergeNoFF("release/1.0.0");
            fixture.AssertFullSemver("1.1.0-alpha.2");

            fixture.Repository.MakeACommit();
            fixture.Repository.Branches.Remove(releaseBranch);

            fixture.AssertFullSemver("1.1.0-alpha.2");
        }
    }
    public void GitFlowPullRequestBranch()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config()))
        {
            fixture.Participant("master");
            fixture.Participant("develop");

            // GitFlow setup
            fixture.Repository.MakeACommit();
            fixture.ApplyTag("1.2.0");
            fixture.BranchTo("develop");

            // Branch to develop
            fixture.MakeACommit();
            fixture.AssertFullSemver("1.3.0-unstable.1");

            // Open Pull Request
            fixture.BranchTo("pull/2/merge", "pr");
            fixture.Activate("pull/2/merge");
            fixture.AssertFullSemver("1.3.0-PullRequest.2+1");
            fixture.MakeACommit();
            fixture.AssertFullSemver("1.3.0-PullRequest.2+2");

            // Merge into develop
            fixture.Checkout("develop");
            fixture.MergeNoFF("pull/2/merge");
            fixture.Destroy("pull/2/merge");
            fixture.NoteOver("Feature branches/pr's should\r\n" +
                             "be deleted once merged", "pull/2/merge");
            fixture.AssertFullSemver("1.3.0-unstable.3");
        }
    }
Exemplo n.º 3
0
    public void GitFlowFeatureBranch()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.SequenceDiagram.Participant("master");
            fixture.SequenceDiagram.Participant("develop");

            // GitFlow setup
            fixture.Repository.MakeACommit();
            fixture.ApplyTag("1.2.0");
            fixture.BranchTo("develop");

            // Branch to develop
            fixture.MakeACommit();
            fixture.AssertFullSemver("1.3.0-unstable.1");

            // Open Pull Request
            fixture.BranchTo("feature/myfeature", "feature");
            fixture.SequenceDiagram.Activate("feature/myfeature");
            fixture.AssertFullSemver("1.3.0-myfeature.1+1");
            fixture.MakeACommit();
            fixture.AssertFullSemver("1.3.0-myfeature.1+2");

            // Merge into develop
            fixture.Checkout("develop");
            fixture.MergeNoFF("feature/myfeature");
            fixture.SequenceDiagram.Destroy("feature/myfeature");
            fixture.SequenceDiagram.NoteOver("Feature branches should\r\n" +
                             "be deleted once merged", "feature/myfeature");
            fixture.AssertFullSemver("1.3.0-unstable.3");
        }
    }
Exemplo n.º 4
0
    public void WhenMergingReleaseBackToDevShouldNotResetBetaVersion()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config()))
        {
            const string TaggedVersion = "1.0.3";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);
            fixture.Repository.CreateBranch("develop");
            fixture.Repository.Checkout("develop");

            fixture.Repository.MakeCommits(1);

            fixture.Repository.CreateBranch("release-2.0.0");
            fixture.Repository.Checkout("release-2.0.0");
            fixture.Repository.MakeCommits(1);

            fixture.AssertFullSemver("2.0.0-beta.1+1");

            //tag it to bump to beta 2
            fixture.Repository.ApplyTag("2.0.0-beta1");

            fixture.Repository.MakeCommits(1);

            fixture.AssertFullSemver("2.0.0-beta.2+0");

            //merge down to develop
            fixture.Repository.Checkout("develop");
            fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());

            //but keep working on the release
            fixture.Repository.Checkout("release-2.0.0");

            fixture.AssertFullSemver("2.0.0-beta.2+0");
        }
    }
Exemplo n.º 5
0
    public void GitFlowPullRequestBranch()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.SequenceDiagram.Participant("master");
            fixture.SequenceDiagram.Participant("develop");

            // GitFlow setup
            fixture.Repository.MakeACommit();
            fixture.ApplyTag("1.2.0");
            fixture.BranchTo("develop");

            // Branch to develop
            fixture.MakeACommit();
            fixture.AssertFullSemver("1.3.0-alpha.1");

            // Open Pull Request
            fixture.BranchTo("pull/2/merge", "pr");
            fixture.SequenceDiagram.Activate("pull/2/merge");
            fixture.AssertFullSemver("1.3.0-PullRequest0002.1");
            fixture.MakeACommit();
            fixture.AssertFullSemver("1.3.0-PullRequest0002.2");

            // Merge into develop
            fixture.Checkout("develop");
            fixture.MergeNoFF("pull/2/merge");
            fixture.SequenceDiagram.Destroy("pull/2/merge");
            fixture.SequenceDiagram.NoteOver("Feature branches/pr's should\r\n" +
                             "be deleted once merged", "pull/2/merge");
            fixture.AssertFullSemver("1.3.0-alpha.3");
            Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
        }
    }
Exemplo n.º 6
0
    public void GitFlowHotfixBranch()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.SequenceDiagram.Participant("develop");
            fixture.SequenceDiagram.Participant("master");

            fixture.Repository.MakeACommit();
            fixture.ApplyTag("1.2.0");

            // Create hotfix branch
            fixture.Checkout("master");
            fixture.BranchTo("hotfix/1.2.1", "hotfix");
            fixture.SequenceDiagram.Activate("hotfix/1.2.1");
            fixture.MakeACommit();
            fixture.MakeACommit();
            fixture.AssertFullSemver("1.2.1-beta.1+2");

            // Apply beta.1 tag should be exact tag
            fixture.ApplyTag("1.2.1-beta.1");
            fixture.AssertFullSemver("1.2.1-beta.1");
            fixture.Checkout("master");
            fixture.MergeNoFF("hotfix/1.2.1");
            fixture.SequenceDiagram.Destroy("hotfix/1.2.1");
            fixture.SequenceDiagram.NoteOver("Hotfix branches are deleted once merged", "hotfix/1.2.1");
            fixture.ApplyTag("1.2.1");
        }
    }
Exemplo n.º 7
0
    public void MinorReleaseExample()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config()))
        {
            fixture.Repository.MakeATaggedCommit("1.2.0");

            // Branch to develop
            fixture.Repository.CreateBranch("develop").Checkout();
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-unstable.1");

            // Open Pull Request
            fixture.Repository.CreateBranch("pull/2/merge").Checkout();
            fixture.AssertFullSemver("1.3.0-PullRequest.2+1");
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-PullRequest.2+2");

            // Merge into develop
            fixture.Repository.Checkout("develop");
            fixture.Repository.MergeNoFF("pull/2/merge", Constants.SignatureNow());
            fixture.AssertFullSemver("1.3.0-unstable.3");

            // Create release branch
            fixture.Repository.CreateBranch("release-1.3.0").Checkout();
            fixture.AssertFullSemver("1.3.0-beta.1+0");

            // Make another commit on develop
            fixture.Repository.Checkout("develop");
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-unstable.4");

            // Make a commit to release-1.3.0
            fixture.Repository.Checkout("release-1.3.0");
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-beta.1+1");

            // Apply beta.1 tag should be exact tag
            fixture.Repository.ApplyTag("1.3.0-beta.1");
            fixture.AssertFullSemver("1.3.0-beta.1");

            // Make a commit after a tag should bump up the beta
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-beta.2+2");

            // Merge release branch to master
            fixture.Repository.Checkout("master");
            fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
            fixture.AssertFullSemver("1.3.0+0");
            fixture.Repository.ApplyTag("1.3.0");

            // Verify develop version
            fixture.Repository.Checkout("develop");
            fixture.AssertFullSemver("1.3.0-unstable.4");
            fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
            // Not 0 for commit count as we can't know the increment rules of the merged branch
            fixture.AssertFullSemver("1.4.0-unstable.2");
        }
    }
Exemplo n.º 8
0
 public void MergingReleaseBranchBackIntoDevelopWithoutMergingToMaster_DoesNotBumpDevelopVersion()
 {
     using (var fixture = new EmptyRepositoryFixture(new Config()))
     {
         fixture.Repository.MakeATaggedCommit("1.0.0");
         fixture.Repository.CreateBranch("develop").Checkout();
         fixture.Repository.CreateBranch("release-2.0.0").Checkout();
         fixture.AssertFullSemver("2.0.0-beta.1+0");
         fixture.Repository.Checkout("develop");
         fixture.AssertFullSemver("1.1.0-unstable.0+0");
         fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());
         fixture.AssertFullSemver("1.1.0-unstable.0+0");
     }
 }
Exemplo n.º 9
0
    public void CanTakeVersionFromReleaseBranch()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeATaggedCommit("1.0.3");
            fixture.Repository.MakeCommits(5);
            fixture.Repository.CreateBranch("release-2.0.0");
            fixture.Repository.Checkout("release-2.0.0");

            fixture.AssertFullSemver("2.0.0-beta.1+0");
            fixture.Repository.MakeCommits(2);
            fixture.AssertFullSemver("2.0.0-beta.1+2");
        }
    }
Exemplo n.º 10
0
    public void CanUseCommitMessagesToBumpVersion()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeACommit();
            fixture.MakeATaggedCommit("1.0.0");
            fixture.Repository.MakeACommit("+semver:minor");

            fixture.AssertFullSemver("1.1.0+1");

            fixture.Repository.MakeACommit("+semver:major");

            fixture.AssertFullSemver("2.0.0+2");
        }
    }
Exemplo n.º 11
0
    public void CanHandleReleaseBranchWithStability()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeATaggedCommit("1.0.3");
            fixture.Repository.CreateBranch("develop");
            fixture.Repository.MakeCommits(5);
            fixture.Repository.CreateBranch("release-2.0.0-Final");
            fixture.Repository.Checkout("release-2.0.0-Final");

            fixture.AssertFullSemver("2.0.0-beta.1+0");
            fixture.Repository.MakeCommits(2);
            fixture.AssertFullSemver("2.0.0-beta.1+2");
        }
    }
Exemplo n.º 12
0
    public void BranchCreatedAfterFastForwardMergeShouldInheritCorrectly()
    {
        var config = new Config();
        config.Branches.Add("unstable", config.Branches["develop"]);

        using (var fixture = new EmptyRepositoryFixture(config))
        {
            fixture.Repository.MakeATaggedCommit("1.0.0");
            fixture.Repository.CreateBranch("unstable");
            fixture.Repository.Checkout("unstable");

            //Create an initial feature branch
            var feature123 = fixture.Repository.CreateBranch("feature/JIRA-123");
            fixture.Repository.Checkout("feature/JIRA-123");
            fixture.Repository.MakeCommits(1);

            //Merge it
            fixture.Repository.Checkout("unstable");
            fixture.Repository.Merge(feature123, SignatureBuilder.SignatureNow());

            //Create a second feature branch
            fixture.Repository.CreateBranch("feature/JIRA-124");
            fixture.Repository.Checkout("feature/JIRA-124");
            fixture.Repository.MakeCommits(1);

            fixture.AssertFullSemver("1.1.0-JIRA-124.1+2");
        }
    }
Exemplo n.º 13
0
    public void BranchCreatedAfterFastForwardMergeShouldInheritCorrectly()
    {
        var config = new Config
        {
            Branches =
            {
                { "unstable", new BranchConfig { Increment = IncrementStrategy.Minor } }
            }
        };

        using (var fixture = new EmptyRepositoryFixture(config))
        {
            fixture.Repository.MakeATaggedCommit("1.0.0");
            fixture.Repository.CreateBranch("unstable");
            fixture.Repository.Checkout("unstable");

            //Create an initial feature branch
            var feature123 = fixture.Repository.CreateBranch("feature/JIRA-123");
            fixture.Repository.Checkout("feature/JIRA-123");
            fixture.Repository.MakeCommits(1);

            //Merge it
            fixture.Repository.Checkout("unstable");
            fixture.Repository.Merge(feature123, Constants.SignatureNow());

            //Create a second feature branch
            fixture.Repository.CreateBranch("feature/JIRA-124");
            fixture.Repository.Checkout("feature/JIRA-124");
            fixture.Repository.MakeCommits(1);

            fixture.AssertFullSemver("1.1.0-JIRA-124.1+2");
        }
    }
Exemplo n.º 14
0
    public void ShouldInheritIncrementCorrectlyWithMultiplePossibleParentsAndWeirdlyNamedDevelopBranch()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config()))
        {
            fixture.Repository.MakeATaggedCommit("1.0.0");
            fixture.Repository.CreateBranch("development");
            fixture.Repository.Checkout("development");

            //Create an initial feature branch
            var feature123 = fixture.Repository.CreateBranch("feature/JIRA-123");
            fixture.Repository.Checkout("feature/JIRA-123");
            fixture.Repository.MakeCommits(1);

            //Merge it
            fixture.Repository.Checkout("development");
            fixture.Repository.Merge(feature123, Constants.SignatureNow());

            //Create a second feature branch
            fixture.Repository.CreateBranch("feature/JIRA-124");
            fixture.Repository.Checkout("feature/JIRA-124");
            fixture.Repository.MakeCommits(1);

            fixture.AssertFullSemver("1.1.0-JIRA-124.1+2");
        }
    }
Exemplo n.º 15
0
    public void AreTagsNotAdheringToTagPrefixIgnored()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config { TagPrefix = "" }))
        {
            string TaggedVersion = "version-1.0.3";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);
            fixture.Repository.MakeCommits(5);

            fixture.AssertFullSemver("0.1.0+5");    //Fallback version + 5 commits since tag

            TaggedVersion = "bad/1.0.3";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);

            fixture.AssertFullSemver("0.1.0+6");   //Fallback version + 6 commits since tag
        }
    }
Exemplo n.º 16
0
    public void CanTakeVersionFromReleaseBranchWithTagOverridden()
    {
        var config = new Config();
        config.Branches["release[/-]"].Tag = "rc";
        using (var fixture = new EmptyRepositoryFixture(config))
        {
            fixture.Repository.MakeATaggedCommit("1.0.3");
            fixture.Repository.MakeCommits(5);
            fixture.Repository.CreateBranch("release-2.0.0");
            fixture.Repository.Checkout("release-2.0.0");

            fixture.AssertFullSemver("2.0.0-rc.1+0");
            fixture.Repository.MakeCommits(2);
            fixture.AssertFullSemver("2.0.0-rc.1+2");
        }
    }
Exemplo n.º 17
0
    public void ShouldBePossibleToMergeDevelopForALongRunningBranchWhereDevelopAndMasterAreEqual()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeATaggedCommit("v1.0.0");

            fixture.Repository.CreateBranch("develop");
            fixture.Repository.Checkout("develop");

            fixture.Repository.CreateBranch("feature/longrunning");
            fixture.Repository.Checkout("feature/longrunning");
            fixture.Repository.MakeACommit();

            fixture.Repository.Checkout("develop");
            fixture.Repository.MakeACommit();

            fixture.Repository.Checkout("master");
            fixture.Repository.Merge(fixture.Repository.Branches["develop"], Generate.SignatureNow());
            fixture.Repository.ApplyTag("v1.1.0");

            fixture.Repository.Checkout("feature/longrunning");
            fixture.Repository.Merge(fixture.Repository.Branches["develop"], Generate.SignatureNow());

            var configuration = new Config { VersioningMode = VersioningMode.ContinuousDeployment };
            fixture.AssertFullSemver(configuration, "1.2.0-longrunning.2");
        }
    }
Exemplo n.º 18
0
    public void CanSpecifyTagPrefixesAsRegex()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config { TagPrefix = "version-|[vV]" }))
        {
            string TaggedVersion = "v1.0.3";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);
            fixture.Repository.MakeCommits(5);

            fixture.AssertFullSemver("1.0.4+5");

            TaggedVersion = "version-1.0.5";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);
            fixture.Repository.MakeCommits(5);

            fixture.AssertFullSemver("1.0.6+5");
        }
    }
Exemplo n.º 19
0
 public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
 {
     using (var fixture = new EmptyRepositoryFixture())
     {
         fixture.Repository.MakeATaggedCommit("1.0.0");
         fixture.Repository.CreateBranch("develop").Checkout();
         fixture.AssertFullSemver("1.1.0-unstable.0+0");
     }
 }
Exemplo n.º 20
0
 public void WhenDevelopBranchedFromTaggedCommitOnMasterVersionDoesNotChange()
 {
     using (var fixture = new EmptyRepositoryFixture())
     {
         fixture.Repository.MakeATaggedCommit("1.0.0");
         fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
         fixture.AssertFullSemver("1.0.0");
     }
 }
Exemplo n.º 21
0
    public void CanUseCommitMessagesToBumpVersionBaseVersionTagIsAppliedToSameCommit()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeACommit();
            fixture.MakeATaggedCommit("1.0.0");
            fixture.Repository.MakeACommit("+semver:minor");
            fixture.AssertFullSemver("1.1.0+1");

            fixture.ApplyTag("2.0.0");

            fixture.Repository.MakeACommit("Hello");

            // Default bump is patch

            fixture.AssertFullSemver("2.0.1+1");
        }
    }
Exemplo n.º 22
0
    public void MasterVersioningContinuousCorrectlyAfterMergingReleaseBranch()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config()))
        {
            fixture.Repository.MakeATaggedCommit("1.0.3");
            fixture.Repository.MakeCommits(1);
            fixture.Repository.CreateBranch("release-2.0.0");
            fixture.Repository.Checkout("release-2.0.0");
            fixture.Repository.MakeCommits(4);
            fixture.Repository.Checkout("master");
            fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());

            fixture.AssertFullSemver("2.0.0+0");
            fixture.Repository.ApplyTag("2.0.0");
            fixture.Repository.MakeCommits(1);
            fixture.AssertFullSemver("2.0.1+1");
        }
    }
Exemplo n.º 23
0
 public void WhenDeveloperBranchExistsDontTreatAsDevelop()
 {
     using (var fixture = new EmptyRepositoryFixture(new Config()))
     {
         fixture.Repository.MakeATaggedCommit("1.0.0");
         fixture.Repository.Checkout(fixture.Repository.CreateBranch("developer"));
         fixture.Repository.MakeACommit();
         fixture.AssertFullSemver("1.0.1-developer.1+1"); // this tag should be the branch name by default, not unstable
     }
 }
Exemplo n.º 24
0
    public void GivenARepositoryWithTagAndANextVersionTxtFileAndNoCommits_VersionShouldBeTag()
    {
        const string ExpectedNextVersion = "1.1.0";
        using (var fixture = new EmptyRepositoryFixture(new Config { NextVersion = ExpectedNextVersion }))
        {
            const string TaggedVersion = "1.0.3";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);

            fixture.AssertFullSemver("1.0.3");
        }
    }
Exemplo n.º 25
0
 public void WhenDevelopBranchedFromMasterWithLegacyVersionTags_DevelopCanUseReachableTag()
 {
     using (var fixture = new EmptyRepositoryFixture())
     {
         fixture.Repository.MakeCommits(5);
         fixture.Repository.MakeATaggedCommit("1.0.0.0");
         fixture.Repository.MakeCommits(2);
         fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
         fixture.AssertFullSemver("1.1.0-alpha.2");
     }
 }
Exemplo n.º 26
0
    public void CanTakeVersionFromReleaseBranchWithTagOverriden()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config { ReleaseBranchTag = "rc" }))
        {
            fixture.Repository.MakeATaggedCommit("1.0.3");
            fixture.Repository.MakeCommits(5);
            fixture.Repository.CreateBranch("release-2.0.0");
            fixture.Repository.Checkout("release-2.0.0");

            fixture.AssertFullSemver("2.0.0-rc.1+5");
        }
    }
Exemplo n.º 27
0
 public void CanClearDevelopTagViaConfig()
 {
     using (var fixture = new EmptyRepositoryFixture(new Config
     {
         DevelopBranchTag = ""
     }))
     {
         fixture.Repository.MakeATaggedCommit("1.0.0");
         fixture.Repository.CreateBranch("develop").Checkout();
         fixture.AssertFullSemver("1.1.0+0");
     }
 }
Exemplo n.º 28
0
    public void CanTakeVersionFromReleaseBranchWithTagOverridden()
    {
        var config = new Config
        {
            Branches =
            {
                { "releases?[/-]", new BranchConfig { Tag = "rc" } }
            }
        };
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeATaggedCommit("1.0.3");
            fixture.Repository.MakeCommits(5);
            fixture.Repository.CreateBranch("release-2.0.0");
            fixture.Repository.Checkout("release-2.0.0");

            fixture.AssertFullSemver(config, "2.0.0-rc.1+0");
            fixture.Repository.MakeCommits(2);
            fixture.AssertFullSemver(config, "2.0.0-rc.1+2");
        }
    }
Exemplo n.º 29
0
 public void CanHandleContinuousDelivery()
 {
     var config = new Config();
     config.Branches["develop"].VersioningMode = VersioningMode.ContinuousDelivery;
     using (var fixture = new EmptyRepositoryFixture(config))
     {
         fixture.Repository.MakeATaggedCommit("1.0.0");
         fixture.Repository.CreateBranch("develop").Checkout();
         fixture.Repository.MakeATaggedCommit("1.1.0-alpha7");
         fixture.AssertFullSemver("1.1.0-alpha.7");
     }
 }
Exemplo n.º 30
0
 public void InheritVersionFromReleaseBranch()
 {
     using (var fixture = new EmptyRepositoryFixture())
     {
         fixture.MakeATaggedCommit("1.0.0");
         fixture.BranchTo("develop");
         fixture.MakeACommit();
         fixture.BranchTo("release/2.0.0");
         fixture.MakeACommit();
         fixture.MakeACommit();
         fixture.Checkout("develop");
         fixture.AssertFullSemver("1.1.0-alpha.1");
         fixture.MakeACommit();
         fixture.AssertFullSemver("2.1.0-alpha.1");
         fixture.MergeNoFF("release/2.0.0");
         fixture.AssertFullSemver("2.1.0-alpha.4");
         fixture.BranchTo("feature/MyFeature");
         fixture.MakeACommit();
         fixture.AssertFullSemver("2.1.0-MyFeature.1+3");
     }
 }
        public void AppliedPrereleaseTagCausesBump()
        {
            var configuration = new TestableConfig
            {
                Branches =
                {
                    {
                        "master", new BranchConfig
                        {
                            Tag            = "pre",
                            SourceBranches = new List <string>()
                        }
                    }
                }
            };

            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeACommit();
            fixture.Repository.MakeATaggedCommit("1.0.0-pre.1");
            fixture.Repository.MakeACommit();

            fixture.AssertFullSemver("1.0.0-pre.2+1", configuration);
        }
Exemplo n.º 32
0
    public void WhenReleaseBranchIsMergedIntoDevelopHighestVersionIsTakenWithIt()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config()))
        {
            fixture.Repository.MakeATaggedCommit("1.0.3");
            fixture.Repository.CreateBranch("develop");
            fixture.Repository.MakeCommits(1);

            fixture.Repository.CreateBranch("release-2.0.0");
            fixture.Repository.Checkout("release-2.0.0");
            fixture.Repository.MakeCommits(4);
            fixture.Repository.Checkout("develop");
            fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());

            fixture.Repository.CreateBranch("release-1.0.0");
            fixture.Repository.Checkout("release-1.0.0");
            fixture.Repository.MakeCommits(4);
            fixture.Repository.Checkout("develop");
            fixture.Repository.MergeNoFF("release-1.0.0", Constants.SignatureNow());

            fixture.AssertFullSemver("2.1.0-unstable.5");
        }
    }
Exemplo n.º 33
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");
            }
        }
Exemplo n.º 34
0
    public void VerifyMergingMasterToFeatureDoesNotCauseBranchCommitsToIncrementVersion()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.MakeACommit("first in master");

            fixture.BranchTo("feature/foo", "foo");
            fixture.MakeACommit("first in foo");

            fixture.Checkout("master");
            fixture.MakeACommit("second in master");

            fixture.Checkout("feature/foo");
            fixture.MergeNoFF("master");
            fixture.MakeACommit("second in foo");

            fixture.Checkout("master");
            fixture.MakeATaggedCommit("1.0.0");

            fixture.MergeNoFF("feature/foo");
            fixture.AssertFullSemver(config, "1.0.1");
        }
    }
Exemplo n.º 35
0
        public void AllowHavingMainInsteadOfMaster()
        {
            var config = new Config();

            config.Branches.Add("master", new BranchConfig
            {
                Regex          = "main",
                VersioningMode = VersioningMode.ContinuousDelivery,
                Tag            = "useBranchName",
                Increment      = IncrementStrategy.Patch,
                PreventIncrementOfMergedBranchVersion = true,
                TrackMergeTarget = false,
                SourceBranches   = new HashSet <string>()
            });

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

            fixture.AssertFullSemver("0.1.0-1+0", config);
        }
Exemplo n.º 36
0
    public void CanUseConventionalCommitsToBumpVersion(string commitMessage, string expectedVersion)
    {
        var configuration = new Config
        {
            VersioningMode = GitVersion.VersionCalculation.VersioningMode.Mainline,

            // For future debugging of this regex: https://regex101.com/r/CRoBol/2
            MajorVersionBumpMessage = "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)",

            // For future debugging of this regex: https://regex101.com/r/9ccNam/3
            MinorVersionBumpMessage = "^(feat)(\\([\\w\\s-]*\\))?:",

            // For future debugging of this regex: https://regex101.com/r/oFpqxA/2
            PatchVersionBumpMessage = "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"
        };

        using var fixture = new EmptyRepositoryFixture();
        fixture.Repository.MakeACommit();
        fixture.MakeATaggedCommit("1.0.0");

        fixture.Repository.MakeACommit(commitMessage);
        fixture.AssertFullSemver(expectedVersion, configuration);
    }
Exemplo n.º 37
0
    public void CanChangeDevelopTagViaConfig()
    {
        var config = new Config
        {
            Branches =
            {
                {
                    "dev(elop)?(ment)?$", new BranchConfig
                    {
                        Tag = "alpha"
                    }
                }
            }
        };

        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeATaggedCommit("1.0.0");
            fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver(config, "1.1.0-alpha.1");
        }
    }
Exemplo n.º 38
0
    public void WhenReleaseBranchIsMergedIntoDevelopHighestVersionIsTakenWithIt()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeATaggedCommit("1.0.3");
            fixture.Repository.CreateBranch("develop");
            fixture.Repository.MakeCommits(1);

            fixture.Repository.CreateBranch("release-2.0.0");
            Commands.Checkout(fixture.Repository, "release-2.0.0");
            fixture.Repository.MakeCommits(4);
            Commands.Checkout(fixture.Repository, "develop");
            fixture.Repository.MergeNoFF("release-2.0.0", Generate.SignatureNow());

            fixture.Repository.CreateBranch("release-1.0.0");
            Commands.Checkout(fixture.Repository, "release-1.0.0");
            fixture.Repository.MakeCommits(4);
            Commands.Checkout(fixture.Repository, "develop");
            fixture.Repository.MergeNoFF("release-1.0.0", Generate.SignatureNow());

            fixture.AssertFullSemver("2.1.0-alpha.11");
        }
    }
Exemplo n.º 39
0
        public void CanChangeDevelopTagViaConfig()
        {
            var config = new Config
            {
                Branches =
                {
                    {
                        "develop",
                        new BranchConfig
                        {
                            Tag            = "alpha",
                            SourceBranches = new HashSet <string>()
                        }
                    }
                }
            };

            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeATaggedCommit("1.0.0");
            Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("develop"));
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.1.0-alpha.1", config);
        }
Exemplo n.º 40
0
    public void CommitsSinceVersionSourceGoesDownWhenDeletingAReleaseBranch()
    {
        var config = new Config
        {
            VersioningMode = VersioningMode.ContinuousDeployment
        };

        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.MakeACommit();
            fixture.ApplyTag("1.1.0");
            fixture.BranchTo("develop");
            fixture.MakeACommit("commit in develop");
            fixture.BranchTo("feature/featureA");
            fixture.MakeACommit("commit in featureA");
            fixture.MakeACommit("commit in featureA");
            fixture.Checkout("develop");
            fixture.MakeACommit("commit in develop");
            fixture.MakeACommit("commit in develop");
            fixture.BranchTo("release/1.2.0");
            fixture.MakeACommit("commit in release/1.2.0");
            fixture.Checkout("feature/featureA");
            fixture.MergeNoFF("develop");
            fixture.Checkout("develop");
            fixture.MergeNoFF("feature/featureA");
            fixture.Checkout("master");
            fixture.MergeNoFF("release/1.2.0");
            fixture.ApplyTag("1.2.0");
            fixture.Checkout("develop");
            fixture.MergeNoFF("release/1.2.0");
            fixture.SequenceDiagram.Destroy("release/1.2.0");
            fixture.Repository.Branches.Remove("release/1.2.0");

            var expectedFullSemVer = "1.3.0-alpha.6";
            fixture.AssertFullSemver(config, expectedFullSemVer);
        }
    }
Exemplo n.º 41
0
    public void GitHubFlowMajorRelease()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config()))
        {
            fixture.Participant("master");

            fixture.Repository.MakeACommit();
            fixture.ApplyTag("1.3.0");

            // Create release branch
            fixture.BranchTo("release/2.0.0", "release");
            fixture.Activate("release/2.0.0");
            fixture.MakeACommit();
            fixture.AssertFullSemver("2.0.0-beta.1+1");
            fixture.MakeACommit();
            fixture.AssertFullSemver("2.0.0-beta.1+2");

            // Apply beta.1 tag should be exact tag
            fixture.ApplyTag("2.0.0-beta.1");
            fixture.AssertFullSemver("2.0.0-beta.1");

            // Make a commit after a tag should bump up the beta
            fixture.MakeACommit();
            fixture.AssertFullSemver("2.0.0-beta.2+3");

            // Complete release
            fixture.Checkout("master");
            fixture.MergeNoFF("release/2.0.0");
            fixture.Destroy("release/2.0.0");
            fixture.NoteOver("Release branches are deleted once merged", "release/2.0.0");

            fixture.AssertFullSemver("2.0.0+0");
            fixture.ApplyTag("2.0.0");
            fixture.AssertFullSemver("2.0.0");
            fixture.MakeACommit();
            fixture.Repository.DumpGraph();
            fixture.AssertFullSemver("2.0.1+1");
        }
    }
Exemplo n.º 42
0
        public void ShouldUseConfiguredTag(string tag, string featureName, string preReleaseTagName)
        {
            var config = new Config
            {
                Branches =
                {
                    { "feature", new BranchConfig {
                          Tag = tag
                      } }
                }
            };

            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeATaggedCommit("1.0.0");
            var featureBranchName = $"feature/{featureName}";

            fixture.Repository.CreateBranch(featureBranchName);
            Commands.Checkout(fixture.Repository, featureBranchName);
            fixture.Repository.MakeCommits(5);

            var expectedFullSemVer = $"1.0.1-{preReleaseTagName}.1+5";

            fixture.AssertFullSemver(config, expectedFullSemVer);
        }
Exemplo n.º 43
0
        public void ShouldInheritIncrementCorrectlyWithMultiplePossibleParentsAndWeirdlyNamedDevelopBranch()
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeATaggedCommit("1.0.0");
            fixture.Repository.CreateBranch("development");
            Commands.Checkout(fixture.Repository, "development");

            //Create an initial feature branch
            var feature123 = fixture.Repository.CreateBranch("feature/JIRA-123");

            Commands.Checkout(fixture.Repository, "feature/JIRA-123");
            fixture.Repository.MakeCommits(1);

            //Merge it
            Commands.Checkout(fixture.Repository, "development");
            fixture.Repository.Merge(feature123, Generate.SignatureNow());

            //Create a second feature branch
            fixture.Repository.CreateBranch("feature/JIRA-124");
            Commands.Checkout(fixture.Repository, "feature/JIRA-124");
            fixture.Repository.MakeCommits(1);

            fixture.AssertFullSemver("1.1.0-JIRA-124.1+2");
        }
Exemplo n.º 44
0
    public void ShouldUseConfiguredTag(string tag, string featureName, string preReleaseTagName)
    {
        var config = new Config
        {
            Branches =
            {
                { "features?[/-]", new BranchConfig {
                      Tag = tag
                  } }
            }
        };

        using (var fixture = new EmptyRepositoryFixture(config))
        {
            fixture.Repository.MakeATaggedCommit("1.0.0");
            var featureBranchName = string.Format("feature/{0}", featureName);
            fixture.Repository.CreateBranch(featureBranchName);
            fixture.Repository.Checkout(featureBranchName);
            fixture.Repository.MakeCommits(5);

            var expectedFullSemVer = string.Format("1.0.1-{0}.1+5", preReleaseTagName);
            fixture.AssertFullSemver(expectedFullSemVer);
        }
    }
Exemplo n.º 45
0
    public void SupportIsCalculatedCorrectly()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config()))
        {
            // Start at 1.0.0
            fixture.Repository.MakeACommit();
            fixture.Repository.ApplyTag("1.1.0");

            // Create 2.0.0 release
            fixture.Repository.CreateBranch("release-2.0.0").Checkout();
            fixture.Repository.MakeCommits(2);

            // Merge into develop and master
            fixture.Repository.Checkout("master");
            fixture.Repository.MergeNoFF("release-2.0.0");
            fixture.Repository.ApplyTag("2.0.0");
            fixture.AssertFullSemver("2.0.0");

            // Now lets support 1.x release
            fixture.Repository.Checkout("1.1.0");
            fixture.Repository.CreateBranch("support/1.0.0").Checkout();
            fixture.AssertFullSemver("1.1.0");

            // Create release branch from support branch
            fixture.Repository.CreateBranch("release/1.2.0").Checkout();
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.2.0-beta.1+1");

            // Create 1.2.0 release
            fixture.Repository.Checkout("support/1.0.0");
            fixture.Repository.MergeNoFF("release/1.2.0");
            fixture.AssertFullSemver("1.2.0+0");
            fixture.Repository.ApplyTag("1.2.0");

            // Create 1.2.1 hotfix
            fixture.Repository.CreateBranch("hotfix/1.2.1").Checkout();
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.2.1-beta.1+1");
            fixture.Repository.Checkout("support/1.0.0");
            fixture.Repository.MergeNoFF("hotfix/1.2.1");
            fixture.AssertFullSemver("1.2.1+2");
        }
    }
    public void VerifyDevelopTracksMasterVersion()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeACommit("1");
            fixture.MakeATaggedCommit("1.0.0");
            fixture.MakeACommit();

            // branching increments the version
            fixture.BranchTo("develop");
            fixture.AssertFullSemver(config, "1.1.0-alpha.0");
            fixture.MakeACommit();
            fixture.AssertFullSemver(config, "1.1.0-alpha.1");

            // merging develop into master increments minor version on master
            fixture.Checkout("master");
            fixture.MergeNoFF("develop");
            fixture.AssertFullSemver(config, "1.1.0");

            // a commit on develop before the merge still has the same version number
            fixture.Checkout("develop");
            fixture.AssertFullSemver(config, "1.1.0-alpha.1");

            // moving on to further work on develop tracks master's version from the merge
            fixture.MakeACommit();
            fixture.AssertFullSemver(config, "1.2.0-alpha.1");

            // adding a commit to master increments patch
            fixture.Checkout("master");
            fixture.MakeACommit();
            fixture.AssertFullSemver(config, "1.1.1");

            // adding a commit to master doesn't change develop's version
            fixture.Checkout("develop");
            fixture.AssertFullSemver(config, "1.2.0-alpha.1");
        }
    }
Exemplo n.º 47
0
    public void CommitsSinceVersionSourceShouldNotGoDownUponGitFlowReleaseFinish()
    {
        var config = new Config
        {
            VersioningMode = VersioningMode.ContinuousDeployment
        };

        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.MakeACommit();
            fixture.ApplyTag("1.1.0");
            fixture.BranchTo("develop");
            fixture.MakeACommit("commit in develop - 1");
            fixture.AssertFullSemver("1.2.0-alpha.1");
            fixture.BranchTo("release/1.2.0");
            fixture.AssertFullSemver("1.2.0-beta.1+0");
            fixture.Checkout("develop");
            fixture.MakeACommit("commit in develop - 2");
            fixture.MakeACommit("commit in develop - 3");
            fixture.MakeACommit("commit in develop - 4");
            fixture.MakeACommit("commit in develop - 5");
            fixture.AssertFullSemver("1.3.0-alpha.4");
            fixture.Checkout("release/1.2.0");
            fixture.MakeACommit("commit in release/1.2.0 - 1");
            fixture.MakeACommit("commit in release/1.2.0 - 2");
            fixture.MakeACommit("commit in release/1.2.0 - 3");
            fixture.AssertFullSemver("1.2.0-beta.1+3");
            fixture.Checkout("master");
            fixture.MergeNoFF("release/1.2.0");
            fixture.ApplyTag("1.2.0");
            fixture.Checkout("develop");
            fixture.MergeNoFF("release/1.2.0");
            fixture.MakeACommit("commit in develop - 6");
            fixture.AssertFullSemver("1.3.0-alpha.9");
            fixture.SequenceDiagram.Destroy("release/1.2.0");
            fixture.Repository.Branches.Remove("release/1.2.0");

            var expectedFullSemVer = "1.3.0-alpha.9";
            fixture.AssertFullSemver(config, expectedFullSemVer);
        }
    }
    public void MergedFeatureBranchesToMasterImpliesRelease()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeACommit("1");
            fixture.MakeATaggedCommit("1.0.0");

            fixture.BranchTo("feature/foo", "foo");
            fixture.MakeACommit("2");
            fixture.AssertFullSemver(config, "1.0.1-foo.1");
            fixture.MakeACommit("2.1");
            fixture.AssertFullSemver(config, "1.0.1-foo.2");
            fixture.Checkout("master");
            fixture.MergeNoFF("feature/foo");

            fixture.AssertFullSemver(config, "1.0.1");

            fixture.BranchTo("feature/foo2", "foo2");
            fixture.MakeACommit("3 +semver: minor");
            fixture.AssertFullSemver(config, "1.1.0-foo2.1");
            fixture.Checkout("master");
            fixture.MergeNoFF("feature/foo2");
            fixture.AssertFullSemver(config, "1.1.0");

            fixture.BranchTo("feature/foo3", "foo3");
            fixture.MakeACommit("4");
            fixture.Checkout("master");
            fixture.MergeNoFF("feature/foo3");
            fixture.SequenceDiagram.NoteOver("Merge message contains '+semver: minor'", "master");
            var commit = fixture.Repository.Head.Tip;
            // Put semver increment in merge message
            fixture.Repository.Commit(commit.Message + " +semver: minor", commit.Author, commit.Committer, new CommitOptions
            {
                AmendPreviousCommit = true
            });
            fixture.AssertFullSemver(config, "1.2.0");

            fixture.BranchTo("feature/foo4", "foo4");
            fixture.MakeACommit("5 +semver: major");
            fixture.AssertFullSemver(config, "2.0.0-foo4.1");
            fixture.Checkout("master");
            fixture.MergeNoFF("feature/foo4");
            fixture.AssertFullSemver(config, "2.0.0");

            // We should evaluate any commits not included in merge commit calculations for direct commit/push or squash to merge commits
            fixture.MakeACommit("6 +semver: major");
            fixture.AssertFullSemver(config, "3.0.0");
            fixture.MakeACommit("7 +semver: minor");
            fixture.AssertFullSemver(config, "3.1.0");
            fixture.MakeACommit("8");
            fixture.AssertFullSemver(config, "3.1.1");

            // Finally verify that the merge commits still function properly
            fixture.BranchTo("feature/foo5", "foo5");
            fixture.MakeACommit("9 +semver: minor");
            fixture.AssertFullSemver(config, "3.2.0-foo5.1");
            fixture.Checkout("master");
            fixture.MergeNoFF("feature/foo5");
            fixture.AssertFullSemver(config, "3.2.0");

            // One more direct commit for good measure
            fixture.MakeACommit("10 +semver: minor");
            fixture.AssertFullSemver(config, "3.3.0");
            // And we can commit without bumping semver
            fixture.MakeACommit("11 +semver: none");
            fixture.AssertFullSemver(config, "3.3.0");
            Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
        }
    }
Exemplo n.º 49
0
    public void MinorReleaseExample()
    {
        using (var fixture = new EmptyRepositoryFixture())
        {
            fixture.Repository.MakeATaggedCommit("1.2.0");

            // Branch to develop
            fixture.Repository.CreateBranch("develop").Checkout();
            fixture.AssertFullSemver("1.3.0-unstable.0+0");

            // Open Pull Request
            fixture.Repository.CreateBranch("pull/2/merge").Checkout();
            fixture.AssertFullSemver("1.3.0-PullRequest.2+0");
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-PullRequest.2+1");

            // Merge into develop
            fixture.Repository.Checkout("develop");
            fixture.Repository.MergeNoFF("pull/2/merge", Constants.SignatureNow());
            fixture.AssertFullSemver("1.3.0-unstable.2+2");

            // Create release branch
            fixture.Repository.CreateBranch("release-1.3.0").Checkout();
            fixture.AssertFullSemver("1.3.0-beta.1+0");

            // Make another commit on develop
            fixture.Repository.Checkout("develop");
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-unstable.3+3");

            // Make a commit to release-1.3.0
            fixture.Repository.Checkout("release-1.3.0");
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-beta.1+1");

            // Apply beta.0 tag should be exact tag
            fixture.Repository.ApplyTag("1.3.0-beta.1");
            fixture.AssertFullSemver("1.3.0-beta.1+1");

            // Make a commit after a tag should bump up the beta
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver("1.3.0-beta.2+2");

            // Merge release branch to master
            fixture.Repository.Checkout("master");
            fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
            fixture.AssertFullSemver("1.3.0");
            fixture.Repository.ApplyTag("1.3.0");

            // Verify develop version
            fixture.Repository.Checkout("develop");
            fixture.Repository.MergeNoFF("release-1.3.0", Constants.SignatureNow());
            fixture.AssertFullSemver("1.4.0-unstable.2+2");
        }
    }
Exemplo n.º 50
0
        public void WhenPreventIncrementOfMergedBranchVersionIsSetToFalseForDevelopCommitsSinceVersionSourceShouldNotGoDownWhenMergingHotfixToDevelop()
        {
            var config = new Config
            {
                VersioningMode = VersioningMode.ContinuousDeployment,
                Branches       = new Dictionary <string, BranchConfig>
                {
                    { "develop", new BranchConfig {
                          PreventIncrementOfMergedBranchVersion = false
                      } },
                    { "hotfix", new BranchConfig {
                          PreventIncrementOfMergedBranchVersion = true, Regex = "^(origin/)?hotfix[/-]"
                      } },
                }
            };

            using var fixture = new EmptyRepositoryFixture();
            fixture.MakeACommit();
            fixture.BranchTo("develop");
            fixture.MakeATaggedCommit("1.0.0");
            fixture.Repository.MakeCommits(1);

            fixture.Checkout("develop");
            fixture.Repository.MakeCommits(3);
            fixture.AssertFullSemver("1.1.0-alpha.4", config);

            const string ReleaseBranch = "release/1.1.0";

            Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch(ReleaseBranch));
            fixture.Repository.MakeCommits(3);
            fixture.AssertFullSemver("1.1.0-beta.3", config);

            // Simulate a GitFlow release finish.
            fixture.Checkout("master");
            fixture.MergeNoFF(ReleaseBranch);
            fixture.ApplyTag("v1.1.0");
            fixture.Checkout("develop");

            // Simulate some work done on develop while the release branch was open.
            fixture.Repository.MakeCommits(2);
            fixture.MergeNoFF(ReleaseBranch);
            fixture.Repository.Branches.Remove(ReleaseBranch);
            fixture.AssertFullSemver("1.2.0-alpha.6", config);

            // Create hotfix for defects found in release/1.1.0
            const string HotfixBranch = "hotfix/1.1.1";

            fixture.Checkout("master");
            Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch(HotfixBranch));
            fixture.Repository.MakeCommits(3);

            // Hotfix finish
            fixture.Checkout("master");
            fixture.Repository.MergeNoFF(HotfixBranch);
            fixture.Repository.ApplyTag("v1.1.1");

            // Verify develop version
            fixture.Checkout("develop");
            // Simulate some work done on develop while the hotfix branch was open.
            fixture.Repository.MakeCommits(3);
            fixture.AssertFullSemver("1.2.0-alpha.9", config);
            fixture.Repository.MergeNoFF(HotfixBranch);
            fixture.AssertFullSemver("1.2.0-alpha.19", config);

            fixture.Repository.Branches.Remove(HotfixBranch);
            fixture.AssertFullSemver("1.2.0-alpha.19", config);
        }
Exemplo n.º 51
0
        public void VerifyIncrementConfigIsHonoured()
        {
            var minorIncrementConfig = new Config
            {
                VersioningMode = VersioningMode.Mainline,
                Increment      = IncrementStrategy.Minor,
                Branches       = new Dictionary <string, BranchConfig>
                {
                    {
                        MainBranch,
                        new BranchConfig
                        {
                            Increment = IncrementStrategy.Minor,
                            Name      = MainBranch,
                            Regex     = MainBranch
                        }
                    },
                    {
                        "feature",
                        new BranchConfig
                        {
                            Increment = IncrementStrategy.Minor,
                            Name      = "feature",
                            Regex     = "features?[/-]"
                        }
                    }
                }
            };

            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeACommit("1");
            fixture.MakeATaggedCommit("1.0.0");

            fixture.BranchTo("feature/foo", "foo");
            fixture.MakeACommit("2");
            fixture.AssertFullSemver("1.1.0-foo.1", minorIncrementConfig);
            fixture.MakeACommit("2.1");
            fixture.AssertFullSemver("1.1.0-foo.2", minorIncrementConfig);
            fixture.Checkout(MainBranch);
            fixture.MergeNoFF("feature/foo");

            fixture.AssertFullSemver("1.1.0", minorIncrementConfig);

            fixture.BranchTo("feature/foo2", "foo2");
            fixture.MakeACommit("3 +semver: patch");
            fixture.AssertFullSemver("1.1.1-foo2.1", minorIncrementConfig);
            fixture.Checkout(MainBranch);
            fixture.MergeNoFF("feature/foo2");
            fixture.AssertFullSemver("1.1.1", minorIncrementConfig);

            fixture.BranchTo("feature/foo3", "foo3");
            fixture.MakeACommit("4");
            fixture.Checkout(MainBranch);
            fixture.MergeNoFF("feature/foo3");
            fixture.SequenceDiagram.NoteOver("Merge message contains '+semver: patch'", MainBranch);
            var commit = fixture.Repository.Head.Tip;

            // Put semver increment in merge message
            fixture.Repository.Commit(commit.Message + " +semver: patch", commit.Author, commit.Committer, new CommitOptions
            {
                AmendPreviousCommit = true
            });
            fixture.AssertFullSemver("1.1.2", minorIncrementConfig);

            fixture.BranchTo("feature/foo4", "foo4");
            fixture.MakeACommit("5 +semver: major");
            fixture.AssertFullSemver("2.0.0-foo4.1", minorIncrementConfig);
            fixture.Checkout(MainBranch);
            fixture.MergeNoFF("feature/foo4");
            fixture.AssertFullSemver("2.0.0", config);

            // We should evaluate any commits not included in merge commit calculations for direct commit/push or squash to merge commits
            fixture.MakeACommit("6 +semver: major");
            fixture.AssertFullSemver("3.0.0", minorIncrementConfig);
            fixture.MakeACommit("7");
            fixture.AssertFullSemver("3.1.0", minorIncrementConfig);
            fixture.MakeACommit("8 +semver: patch");
            fixture.AssertFullSemver("3.1.1", minorIncrementConfig);

            // Finally verify that the merge commits still function properly
            fixture.BranchTo("feature/foo5", "foo5");
            fixture.MakeACommit("9 +semver: patch");
            fixture.AssertFullSemver("3.1.2-foo5.1", minorIncrementConfig);
            fixture.Checkout(MainBranch);
            fixture.MergeNoFF("feature/foo5");
            fixture.AssertFullSemver("3.1.2", minorIncrementConfig);

            // One more direct commit for good measure
            fixture.MakeACommit("10 +semver: patch");
            fixture.AssertFullSemver("3.1.3", minorIncrementConfig);
            // And we can commit without bumping semver
            fixture.MakeACommit("11 +semver: none");
            fixture.AssertFullSemver("3.1.3", minorIncrementConfig);
            Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
        }
Exemplo n.º 52
0
        public void Bugfix_on_release_branch()
        {
            using var fixture = new EmptyRepositoryFixture();
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver(config, "0.1.0-beta.1+0");

            fixture.Repository.CreateBranch("release/1.26");
            fixture.Repository.MakeACommit(); //to make sure master runs with 27 at this time
            fixture.AssertFullSemver(config, "1.27.0-beta.1+1");
            fixture.Checkout("release/1.26");

            fixture.AssertFullSemver(config, "1.26.0+0");
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver(config, "1.26.0+1");

            fixture.Repository.CreateBranch("hotfix/on-release-branch");
            fixture.Checkout("hotfix/on-release-branch");
            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver(config, "1.26.1-on-release-branch.1+1"); //why 1.26.1, with patch=1 only on hotfix and not when returning into release branch

            fixture.Repository.MakeACommit();
            fixture.AssertFullSemver(config, "1.26.1-on-release-branch.1+2");

            var commit = fixture.Repository.CreatePullRequestRef("hotfix/on-release-branch", "release/1.26", normalise: true);

            fixture.AssertFullSemver(config, "1.27.0-PullRequest0002.3"); //where did 27 come from?
            fixture.Checkout("release/1.26");
            fixture.Repository.Merge(commit, Generate.SignatureNow());
            fixture.AssertFullSemver(config, "1.26.0+4");

            Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("merge/1-26-to-master"));
            fixture.AssertFullSemver(config, "0.1.0-merge-1-26-to-master.1+4");

            var backToMasterCommit = fixture.Repository.CreatePullRequestRef("merge/1-26-to-master", "master", 3, normalise: true);

            fixture.AssertFullSemver(config, "0.1.0-PullRequest0003.6");

            fixture.Checkout("master");
            fixture.Repository.Merge(commit, Generate.SignatureNow());
            fixture.AssertFullSemver(config, "1.27.0-beta.1+6");
        }