Exemplo n.º 1
0
        public VersionAndBranch GetBuildNumber(GitVersionContext context)
        {
            var commit = lastTaggedReleaseFinder.GetVersion().Commit;
            var commitsSinceLastRelease = NumberOfCommitsOnBranchSinceCommit(gitRepo.Head, commit);
            var semanticVersion         = nextSemverCalculator.NextVersion();

            semanticVersion.PreReleasePartTwo = commitsSinceLastRelease;
            if (context.CurrentBranch.IsPullRequest())
            {
                EnsurePullBranchShareACommonAncestorWithMaster(gitRepo, gitRepo.Head);
                var extractIssueNumber = ExtractIssueNumber(context);
                semanticVersion.Tag    = "unstable" + extractIssueNumber;
                semanticVersion.Suffix = extractIssueNumber;
                return(new VersionAndBranch
                {
                    BranchName = context.CurrentBranch.Name,
                    BranchType = BranchType.PullRequest,
                    Sha = context.CurrentBranch.Tip.Sha,
                    Version = semanticVersion
                });
            }

            return(new VersionAndBranch
            {
                BranchName = context.CurrentBranch.Name,
                BranchType = BranchType.Master,
                Sha = context.CurrentBranch.Tip.Sha,
                Version = semanticVersion
            });
        }
Exemplo n.º 2
0
        public SemanticVersion GetBuildNumber(GitVersionContext context)
        {
            var commitsSinceLastRelease = GetCommitsSinceLastRelease(context);
            var semanticVersion         = nextSemverCalculator.NextVersion();

            // TODO Need a way of setting this in a cross cutting way
            semanticVersion.BuildMetaData = new SemanticVersionBuildMetaData(commitsSinceLastRelease, context.CurrentBranch.Name, context.CurrentCommit.Sha, context.CurrentCommit.When());
            if (context.CurrentBranch.IsPullRequest())
            {
                EnsurePullBranchShareACommonAncestorWithMaster(gitRepo, gitRepo.Head);
                var extractIssueNumber = ExtractIssueNumber(context);
                semanticVersion.PreReleaseTag = "PullRequest" + extractIssueNumber;
                return(semanticVersion);
            }

            return(semanticVersion);
        }
Exemplo n.º 3
0
        public SemanticVersion GetBuildNumber(GitVersionContext context)
        {
            var commit = lastTaggedReleaseFinder.GetVersion().Commit;
            var commitsSinceLastRelease = NumberOfCommitsOnBranchSinceCommit(context, commit);
            var semanticVersion         = nextSemverCalculator.NextVersion();

            var sha         = context.CurrentCommit.Sha;
            var releaseDate = ReleaseDateFinder.Execute(context.Repository, sha, semanticVersion.Patch);

            // TODO Need a way of setting this in a cross cutting way
            semanticVersion.BuildMetaData = new SemanticVersionBuildMetaData(commitsSinceLastRelease,
                                                                             context.CurrentBranch.Name, releaseDate);
            if (context.CurrentBranch.IsPullRequest())
            {
                EnsurePullBranchShareACommonAncestorWithMaster(gitRepo, gitRepo.Head);
                var extractIssueNumber = ExtractIssueNumber(context);
                semanticVersion.PreReleaseTag = "PullRequest" + extractIssueNumber;
                return(semanticVersion);
            }

            return(semanticVersion);
        }