IEnumerable <BaseVersion> GetReleaseVersion(GitVersionContext context, Branch releaseBranch) { var tagPrefixRegex = context.Configuration.GitTagPrefix; var repository = context.Repository; var baseSource = releaseBranch.FindMergeBase(context.CurrentBranch, repository); return(releaseVersionStrategy .GetVersions(tagPrefixRegex, releaseBranch, repository) .Select(b => new BaseVersion(b.Source, true, b.SemanticVersion, baseSource, b.BranchNameOverride))); }
public void CanTakeVersionFromBranchName(string branchName, string expectedBaseVersion) { using (var fixture = new EmptyRepositoryFixture()) { fixture.Repository.MakeACommit(); var branch = fixture.Repository.CreateBranch(branchName); var sut = new VersionInBranchBaseVersionStrategy(); 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); } } }