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);
        }
    }
Exemplo n.º 2
0
    void AssertInvalidPullBranchName(string invalidFakePullBranchName)
    {
        var repoPath = Clone(ASBMTestRepoWorkingDirPath);
        using (var repo = new Repository(repoPath))
        {
            var branchingCommit = repo.Branches["develop"].Tip;
            var pullBranch = repo.Branches.Add(invalidFakePullBranchName, branchingCommit);

            var finder = new PullVersionFinder();

            Assert.Throws<WarningException>(() => finder.FindVersion(new GitVersionContext(repo, pullBranch)));
        }
    }