コード例 #1
0
    public void Feature_branch_with_2_commits()
    {
        var repoPath = Clone(ASBMTestRepoWorkingDirPath);

        using (var repo = new Repository(repoPath))
        {
            // Create a feature branch from the parent of current develop tip
            repo.Branches.Add("featureWithOneCommit", "develop~").ForceCheckout();
            //var branchingCommit = repo.Head.Tip;

            AddOneCommitToHead(repo, "feature");
            AddOneCommitToHead(repo, "feature");

            var featureBranch = repo.Branches["featureWithOneCommit"];

            var finder = new FeatureVersionFinder();

            var version = finder.FindVersion(new GitVersionContext
            {
                Repository    = repo,
                CurrentBranch = featureBranch
            });

            var masterVersion = FindersHelper.RetrieveMasterVersion(repo);

            Assert.AreEqual(masterVersion.Minor + 1, version.Minor, "Minor should be master.Minor+1");
            //TODO Assert.AreEqual(branchingCommit.Prefix(), version.Version.Suffix, "Suffix should be the develop commit it was branched from");
            ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber);
        }
    }
コード例 #2
0
    public void Pull_branch_with_2_commits()
    {
        var repoPath = Clone(ASBMTestRepoWorkingDirPath);

        using (var repo = new Repository(repoPath))
        {
            // Create a pull request branch from the parent of current develop tip
            repo.Branches.Add("pull/1735/merge", "develop~").ForceCheckout();

            AddOneCommitToHead(repo, "code");
            AddOneCommitToHead(repo, "more code");

            var pullBranch = repo.Head;

            var finder = new PullVersionFinder();

            var version = finder.FindVersion(new GitVersionContext
            {
                Repository    = repo,
                CurrentBranch = pullBranch,
            });

            var masterVersion = FindersHelper.RetrieveMasterVersion(repo);

            Assert.AreEqual(masterVersion.Minor + 1, version.Minor, "Minor should be master.Minor+1");
            Assert.AreEqual(1735, version.PreReleaseTag.Number);
            ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber);
        }
    }
コード例 #3
0
    [Ignore] //TODO Delete?
    public void Feature_branch_with_no_commit()
    {
        //this scenario should redirect to the develop finder since there is no diff btw this branch and the develop branch

        var repoPath = Clone(ASBMTestRepoWorkingDirPath);

        using (var repo = new Repository(repoPath))
        {
            var branchingCommit = repo.Branches["develop"].Tip;
            var featureBranch   = repo.Branches.Add("featureWithNoCommits", branchingCommit);

            var finder = new FeatureVersionFinder();

            var version = finder.FindVersion(new GitVersionContext
            {
                Repository    = repo,
                CurrentBranch = featureBranch
            });

            var masterVersion = FindersHelper.RetrieveMasterVersion(repo);

            Assert.AreEqual(masterVersion.Minor + 1, version.Minor, "Minor should be master.Minor+1");
            ObjectApprover.VerifyWithJson(version, Scrubbers.GuidScrubber);
        }
    }