当前位置: 首页>>代码示例>>C#>>正文


C# GitVersionContext类代码示例

本文整理汇总了C#中GitVersionContext的典型用法代码示例。如果您正苦于以下问题:C# GitVersionContext类的具体用法?C# GitVersionContext怎么用?C# GitVersionContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GitVersionContext类属于命名空间,在下文中一共展示了GitVersionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetVersions

        public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
        {
            var olderThan = context.CurrentCommit.When();
            var allTags = context.Repository.Tags
                .Where(tag => ((Commit)tag.PeeledTarget()).When() <= olderThan)
                .ToList();
            var tagsOnBranch = context.CurrentBranch
                .Commits
                .SelectMany(commit =>
                {
                    return allTags.Where(t => IsValidTag(t, commit));
                })
                .Select(t =>
                {
                    SemanticVersion version;
                    if (SemanticVersion.TryParse(t.Name, context.Configuration.GitTagPrefix, out version))
                    {
                        var commit = t.PeeledTarget() as Commit;
                        if (commit != null)
                            return new VersionTaggedCommit(commit, version, t.Name);
                    }
                    return null;
                })
                .Where(a => a != null)
                .ToList();

            return tagsOnBranch.Select(t => CreateBaseVersion(context, t));
        }
开发者ID:whearn-volusion,项目名称:GitVersion,代码行数:28,代码来源:TaggedCommitVersionStrategy.cs

示例2: GetBaseVersion

        public BaseVersion GetBaseVersion(GitVersionContext context)
        {
            Logger.WriteInfo("Base Versions:");

            var baseVersion = strategies
                .Select(s => s.GetVersion(context))
                .Where(v =>
                {
                    if (v != null)
                    {
                        Logger.WriteInfo(v.ToString());
                        return true;
                    }

                    return false;
                })
                .Aggregate((v1, v2) =>
                {
                    if (v1.SemanticVersion > v2.SemanticVersion)
                    {
                        return new BaseVersion(v1.Source, v1.ShouldIncrement, v1.SemanticVersion, v1.BaseVersionSource ?? v2.BaseVersionSource, v1.BranchNameOverride);
                    }

                    return new BaseVersion(v2.Source, v2.ShouldIncrement, v2.SemanticVersion, v2.BaseVersionSource ?? v1.BaseVersionSource, v2.BranchNameOverride);
                });

            Logger.WriteInfo(string.Format("Base version used: {0}", baseVersion));

            return baseVersion;
        }
开发者ID:Wikell,项目名称:GitVersion,代码行数:30,代码来源:BaseVersionCalculator.cs

示例3: GetVersions

 public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
 {
     if (string.IsNullOrEmpty(context.Configuration.NextVersion) || context.IsCurrentCommitTagged)
         yield break;
     var semanticVersion = SemanticVersion.Parse(context.Configuration.NextVersion, context.Configuration.GitTagPrefix);
     yield return new BaseVersion("NextVersion in GitVersionConfig.yaml", false, semanticVersion, null, null);
 }
开发者ID:pierrebakker,项目名称:GitVersion,代码行数:7,代码来源:ConfigNextVersionBaseVersionStrategy.cs

示例4: FindVersion

        public SemanticVersion FindVersion(GitVersionContext context)
        {
            // If current commit is tagged, don't do anything except add build metadata
            if (context.IsCurrentCommitTagged)
            {
                // Will always be 0, don't bother with the +0 on tags
                var semanticVersionBuildMetaData = metaDataCalculator.Create(context.CurrentCommit, context);
                semanticVersionBuildMetaData.CommitsSinceTag = null;
                var semanticVersion = new SemanticVersion(context.CurrentCommitTaggedVersion)
                {
                    BuildMetaData = semanticVersionBuildMetaData
                };
                return semanticVersion;
            }

            var baseVersion = baseVersionFinder.GetBaseVersion(context);

            if (baseVersion.ShouldIncrement) IncrementVersion(context, baseVersion);
            else Logger.WriteInfo("Skipping version increment");

            if (!baseVersion.SemanticVersion.PreReleaseTag.HasTag() && !string.IsNullOrEmpty(context.Configuration.Tag))
            {
                UpdatePreReleaseTag(context, baseVersion);
            }

            baseVersion.SemanticVersion.BuildMetaData = metaDataCalculator.Create(baseVersion.BaseVersionSource, context);

            return baseVersion.SemanticVersion;
        }
开发者ID:Wikell,项目名称:GitVersion,代码行数:29,代码来源:NextVersionCalculator.cs

示例5: ExtractIssueNumber

        string ExtractIssueNumber(GitVersionContext context)
        {
            const string prefix = "/pull/";
            var pullRequestBranch = context.CurrentBranch;

            var start = pullRequestBranch.CanonicalName.IndexOf(prefix, System.StringComparison.Ordinal);
            var end = pullRequestBranch.CanonicalName.LastIndexOf("/merge", pullRequestBranch.CanonicalName.Length - 1,
                System.StringComparison.Ordinal);

            string issueNumber = null;

            if (start != -1 && end != -1 && start + prefix.Length <= end)
            {
                start += prefix.Length;
                issueNumber = pullRequestBranch.CanonicalName.Substring(start, end - start);
            }

            if (!LooksLikeAValidPullRequestNumber(issueNumber))
            {
                throw new WarningException(string.Format("Unable to extract pull request number from '{0}'.",
                    pullRequestBranch.CanonicalName));
            }

            return issueNumber;
        }
开发者ID:robdmoore,项目名称:GitVersion,代码行数:25,代码来源:PullVersionFinder.cs

示例6: ReleaseBranchBaseVersions

        private IEnumerable<BaseVersion> ReleaseBranchBaseVersions(GitVersionContext context)
        {
            var releaseBranchConfig = context.FullConfiguration.Branches
                .Where(b => b.Value.IsReleaseBranch == true)
                .ToList();
            if (releaseBranchConfig.Any())
            {
                var releaseBranches = context.Repository.Branches
                    .Where(b => releaseBranchConfig.Any(c => Regex.IsMatch(b.FriendlyName, c.Key)));

                return releaseBranches
                    .SelectMany(b => GetReleaseVersion(context, b))
                    .Select(baseVersion =>
                    {
                        // Need to drop branch overrides and give a bit more context about
                        // where this version came from
                        var source1 = "Release branch exists -> " + baseVersion.Source;
                        return new BaseVersion(source1,
                            baseVersion.ShouldIncrement,
                            baseVersion.SemanticVersion,
                            baseVersion.BaseVersionSource,
                            null);
                    })
                    .ToList();
            }
            return new BaseVersion[0];
        }
开发者ID:qetza,项目名称:GitVersion,代码行数:27,代码来源:DevelopVersionStrategy.cs

示例7: GetVersions

 public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
 {
     var currentBranch = context.CurrentBranch;
     var tagPrefixRegex = context.Configuration.GitTagPrefix;
     var repository = context.Repository;
     return GetVersions(context, tagPrefixRegex, currentBranch, repository);
 }
开发者ID:asbjornu,项目名称:GitVersion,代码行数:7,代码来源:VersionInBranchNameBaseVersionStrategy.cs

示例8: FindVersion

        public SemanticVersion FindVersion(GitVersionContext context)
        {
            if (context.CurrentBranch.IsMaster())
            {
                return new MasterVersionFinder().FindVersion(context.Repository, context.CurrentBranch.Tip);
            }

            if (context.CurrentBranch.IsHotfix())
            {
                return new HotfixVersionFinder().FindVersion(context);
            }

            if (context.CurrentBranch.IsRelease())
            {
                return new ReleaseVersionFinder().FindVersion(context);
            }

            if (context.CurrentBranch.IsDevelop())
            {
                return new DevelopVersionFinder().FindVersion(context);
            }

            if (context.CurrentBranch.IsPullRequest())
            {
                return new PullVersionFinder().FindVersion(context);
            }

            if (context.CurrentBranch.IsSupport())
            {
                return new SupportVersionFinder().FindVersion(context.Repository, context.CurrentBranch.Tip);
            }

            return new FeatureVersionFinder().FindVersion(context);
        }
开发者ID:potherca-contrib,项目名称:GitVersion,代码行数:34,代码来源:GitFlowVersionFinder.cs

示例9: FindVersion

        public SemanticVersion FindVersion(GitVersionContext context)
        {
            // If current commit is tagged, don't do anything except add build metadata
            if (context.IsCurrentCommitTagged)
            {
                // Will always be 0, don't bother with the +0 on tags
                var semanticVersionBuildMetaData = metaDataCalculator.Create(context.CurrentCommit, context);
                semanticVersionBuildMetaData.CommitsSinceTag = null;
                var semanticVersion = new SemanticVersion(context.CurrentCommitTaggedVersion)
                {
                    BuildMetaData = semanticVersionBuildMetaData
                };
                return semanticVersion;
            }

            var baseVersion = baseVersionFinder.GetBaseVersion(context);
            var semver = baseVersion.SemanticVersion;
            var increment = IncrementStrategyFinder.DetermineIncrementedField(context, baseVersion);
            if (increment != null)
            {
                semver = semver.IncrementVersion(increment.Value);
            }
            else Logger.WriteInfo("Skipping version increment");

            if (!semver.PreReleaseTag.HasTag() && !string.IsNullOrEmpty(context.Configuration.Tag))
            {
                UpdatePreReleaseTag(context, semver, baseVersion.BranchNameOverride);
            }

            semver.BuildMetaData = metaDataCalculator.Create(baseVersion.BaseVersionSource, context);

            return semver;
        }
开发者ID:nphmuller,项目名称:GitVersion,代码行数:33,代码来源:NextVersionCalculator.cs

示例10: GetVersions

 public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
 {
     var baseVersionSource = context.Repository.Commits.QueryBy(new CommitFilter
     {
         IncludeReachableFrom = context.CurrentBranch.Tip
     }).First(c => !c.Parents.Any());
     yield return new BaseVersion("Fallback base version", false, new SemanticVersion(minor: 1), baseVersionSource, null);
 }
开发者ID:qetza,项目名称:GitVersion,代码行数:8,代码来源:FallbackBaseVersionStrategy.cs

示例11: FindVersion

 public SemanticVersion FindVersion(GitVersionContext context)
 {
     var repositoryDirectory = context.Repository.Info.WorkingDirectory;
     var lastTaggedReleaseFinder = new LastTaggedReleaseFinder(context);
     var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repositoryDirectory);
     var nextSemverCalculator = new NextSemverCalculator(nextVersionTxtFileFinder, lastTaggedReleaseFinder, context);
     return new BuildNumberCalculator(nextSemverCalculator, lastTaggedReleaseFinder, context.Repository).GetBuildNumber(context);
 }
开发者ID:hbre,项目名称:GitVersion,代码行数:8,代码来源:GitHubFlowVersionFinder.cs

示例12: GetBaseVersion

        public BaseVersion GetBaseVersion(GitVersionContext context)
        {
            using (Logger.IndentLog("Calculating base versions"))
            {
                var baseVersions = strategies
                    .SelectMany(s => s.GetVersions(context))
                    .Where(v =>
                    {
                        if (v != null)
                        {
                            Logger.WriteInfo(v.ToString());
                            return true;
                        }

                        return false;
                    })
                    .Select(v => new
                    {
                        IncrementedVersion = MaybeIncrement(context, v),
                        Version = v
                    })
                    .ToList();

                var maxVersion = baseVersions.Aggregate((v1, v2) => v1.IncrementedVersion > v2.IncrementedVersion ? v1 : v2);
                var matchingVersionsOnceIncremented = baseVersions
                    .Where(b => b != maxVersion && b.Version.BaseVersionSource != null && b.IncrementedVersion == maxVersion.IncrementedVersion)
                    .ToList();
                BaseVersion baseVersionWithOldestSource;
                if (matchingVersionsOnceIncremented.Any())
                {
                    baseVersionWithOldestSource = matchingVersionsOnceIncremented.Aggregate((v1, v2) => v1.Version.BaseVersionSource.Committer.When < v2.Version.BaseVersionSource.Committer.When ? v1 : v2).Version;
                    Logger.WriteInfo(string.Format(
                        "Found multiple base versions which will produce the same SemVer ({0}), taking oldest source for commit counting ({1})",
                        maxVersion.IncrementedVersion,
                        baseVersionWithOldestSource.Source));
                }
                else
                {
                    baseVersionWithOldestSource = baseVersions
                        .Where(v => v.Version.BaseVersionSource != null)
                        .OrderByDescending(v => v.IncrementedVersion)
                        .ThenByDescending(v => v.Version.BaseVersionSource.Committer.When)
                        .First()
                        .Version;
                }

                if (baseVersionWithOldestSource.BaseVersionSource == null)
                    throw new Exception("Base version should not be null");

                var calculatedBase = new BaseVersion(
                    maxVersion.Version.Source, maxVersion.Version.ShouldIncrement, maxVersion.Version.SemanticVersion,
                    baseVersionWithOldestSource.BaseVersionSource, maxVersion.Version.BranchNameOverride);

                Logger.WriteInfo(string.Format("Base version used: {0}", calculatedBase));

                return calculatedBase;
            }
        }
开发者ID:petegee,项目名称:GitVersion,代码行数:58,代码来源:BaseVersionCalculator.cs

示例13: GetVersions

        public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
        {
            if (context.Configuration.IsCurrentBranchDevelop)
            {
                return ReleaseBranchBaseVersions(context).Union(MasterTagsVersions(context));
            }

            return new BaseVersion[0];
        }
开发者ID:qetza,项目名称:GitVersion,代码行数:9,代码来源:DevelopVersionStrategy.cs

示例14: BaseVersion

 public BaseVersion(GitVersionContext context, string source, bool shouldIncrement, SemanticVersion semanticVersion, Commit baseVersionSource, string branchNameOverride)
 {
     Source = source;
     ShouldIncrement = shouldIncrement;
     SemanticVersion = semanticVersion;
     BaseVersionSource = baseVersionSource;
     BranchNameOverride = branchNameOverride;
     _context = context;
 }
开发者ID:asbjornu,项目名称:GitVersion,代码行数:9,代码来源:BaseVersion.cs

示例15: FindVersion

        public SemanticVersion FindVersion(GitVersionContext context)
        {
            var issueNumber = ExtractIssueNumber(context);

            var version = FindVersion(context, BranchType.PullRequest);
            version.PreReleaseTag = new SemanticVersionPreReleaseTag("PullRequest", int.Parse(issueNumber));
            //TODO version.Version.BuildMetaData = NumberOfCommitsOnBranchSinceCommit(context.CurrentBranch, commonAncestor);
            return version;
        }
开发者ID:robdmoore,项目名称:GitVersion,代码行数:9,代码来源:PullVersionFinder.cs


注:本文中的GitVersionContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。