Пример #1
0
 public void Override_using_tag_with_a_prerelease()
 {
     var commit = new MockCommit
     {
         CommitterEx = 2.Seconds().Ago().ToSignature()
     };
     var finder = new MasterVersionFinder();
     var mockBranch = new MockBranch("master")
     {
         commit
     };
     var mockRepository = new MockRepository
     {
         Branches = new MockBranchCollection
         {
             mockBranch
         },
         Tags = new MockTagCollection
         {
             new MockTag
             {
                 NameEx = "0.1.0-beta1",
                 TargetEx = commit
             }
         }
     };
     var version = finder.FindVersion(new GitVersionContext(mockRepository, mockBranch, new Config()));
     Assert.AreEqual(0, version.Patch, "Should set the patch version to the patch of the latest hotfix merge commit");
     ObjectApprover.VerifyWithJson(version, Scrubbers.GuidScrubber);
 }
Пример #2
0
 public void Override_using_tag_with_a_stable_release()
 {
     var commit = new MockCommit
     {
         CommitterEx = 2.Seconds().Ago().ToSignature()
     };
     var finder = new MasterVersionFinder();
     var version = finder.FindVersion(
         new MockRepository
         {
             Branches = new MockBranchCollection
             {
                 new MockBranch("master")
                 {
                     commit
                 },
             },
             Tags = new MockTagCollection
             {
                 new MockTag
                 {
                     NameEx = "0.2.0",
                     TargetEx = commit
                 }
             }
         }, commit);
     Assert.AreEqual(0, version.Patch, "Should set the patch version to the patch of the latest hotfix merge commit");
     ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber);
 }
Пример #3
0
    public void Hotfix_merge()
    {
        var hotfixMergeCommit = new MockMergeCommit
                         {
                             MessageEx = "Merge branch 'hotfix-0.1.5'",
                             CommitterEx = 2.Seconds().Ago().ToSignature()
                         };
        var finder = new MasterVersionFinder();
        var version = finder.FindVersion(
            new MockRepository
            {
                Branches = new MockBranchCollection
                {
                    new MockBranch("master")
                    {
                        hotfixMergeCommit
                    },
                }
            }, hotfixMergeCommit);

        Assert.AreEqual(5, version.Patch, "Should set the patch version to the patch of the latest hotfix merge commit");
        ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber);
    }
Пример #4
0
 public static SemanticVersion RetrieveMasterVersion(Repository repo, Config configuration)
 {
     var masterFinder = new MasterVersionFinder();
     var masterVersion = masterFinder.FindVersion(new GitVersionContext(repo, repo.Branches["master"], configuration));
     return masterVersion;
 }
Пример #5
0
 public static SemanticVersion RetrieveMasterVersion(Repository repo)
 {
     var masterFinder = new MasterVersionFinder();
     var masterVersion = masterFinder.FindVersion(repo, repo.Branches["master"].Tip);
     return masterVersion;
 }
Пример #6
0
    public void Should_throw_if_head_isnt_a_merge_commit_and_no_override_tag_is_found()
    {
        var commit = new MockCommit
                     {
                         MessageEx = "Not a merge commit",
                         CommitterEx = 2.Seconds().Ago().ToSignature()
                     };
        var finder = new MasterVersionFinder();

        var mockBranch = new MockBranch("master")
            {
                commit
            };
        var mockRepository = new MockRepository
        {
            Branches = new MockBranchCollection
                {
                    mockBranch,
                }
        };
        var exception = Assert.Throws<WarningException>(() =>
        {
            finder.FindVersion(new GitVersionContext(mockRepository, mockBranch, new Config()));
        });
        Assert.AreEqual("The head of master should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.", exception.Message);
    }
Пример #7
0
 public void Release_merge()
 {
     var commit = new MockMergeCommit
     {
         CommitterEx = 2.Seconds().Ago().ToSignature(),
         MessageEx = "Merge branch 'release-0.2.0'"
     };
     var finder = new MasterVersionFinder();
     var mockBranch = new MockBranch("master")
     {
         commit
     };
     var mockRepository = new MockRepository
     {
         Branches = new MockBranchCollection
         {
             mockBranch
         },
     };
     var version = finder.FindVersion(new GitVersionContext(mockRepository, mockBranch, new Config()));
     Assert.AreEqual(0, version.Patch, "Should set the patch version to 0");
     ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber);
 }