• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GitVersion.GitVersionContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Execute

        public VersionPoint Execute(GitVersionContext context, DateTimeOffset olderThan)
        {
            var masterBranch = context.Repository.FindBranch("master");
            foreach (var commit in masterBranch.CommitsPriorToThan(olderThan))
            {
                foreach (var tag in context.Repository.TagsByDate(commit))
                {
                    SemanticVersion semanticVersion;
                    if (SemanticVersion.TryParse(tag.Name, context.Configuration.TagPrefix, out semanticVersion))
                    {
                        return new VersionPoint
                        {
                            Major = semanticVersion.Major,
                            Minor = semanticVersion.Minor,
                        };
                    }
                }

                SemanticVersion semanticVersionFromMergeMessage;
                if (MergeMessageParser.TryParse(commit, context.Configuration, out semanticVersionFromMergeMessage))
                {
                    return new VersionPoint
                    {
                        Major = semanticVersionFromMergeMessage.Major,
                        Minor = semanticVersionFromMergeMessage.Minor,
                    };
                }
            }
            return new VersionPoint
            {
                Major = 0,
                Minor = 1,
            };
        }
开发者ID:unic,项目名称:GitVersion,代码行数:34,代码来源:VersionOnMasterFinder.cs


示例2: FindVersion

        public bool FindVersion(GitVersionContext context, out SemanticVersion semanticVersion)
        {
            var versionString = GetUnknownBranchSuffix(context.CurrentBranch);
            if (!versionString.Contains("."))
            {
                semanticVersion = null;
                return false;
            }
            var shortVersion = SemanticVersion.Parse(versionString, context.Configuration.TagPrefix);

            var applicableTagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(context.Configuration, shortVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name, context.Configuration.TagPrefix)).ToList();
            var nbHotfixCommits = BranchCommitDifferenceFinder.NumberOfCommitsSinceLastTagOrBranchPoint(context, applicableTagsInDescendingOrder, BranchType.Unknown, "master");
            var semanticVersionPreReleaseTag = RecentTagVersionExtractor.RetrieveMostRecentOptionalTagVersion(context, applicableTagsInDescendingOrder) ?? CreateDefaultPreReleaseTag(context, versionString);

            if (semanticVersionPreReleaseTag.Name == "release")
            {
                semanticVersionPreReleaseTag.Name = context.Configuration.ReleaseBranchTag;
            }

            semanticVersion = new SemanticVersion
            {
                Major = shortVersion.Major,
                Minor = shortVersion.Minor,
                Patch = shortVersion.Patch,
                PreReleaseTag = semanticVersionPreReleaseTag,
                BuildMetaData = new SemanticVersionBuildMetaData(nbHotfixCommits, context.CurrentBranch.Name, context.CurrentCommit.Sha, context.CurrentCommit.When())
            };
            return true;
        }
开发者ID:unic,项目名称:GitVersion,代码行数:29,代码来源:OtherBranchVersionFinder.cs


示例3: FindVersion

        public SemanticVersion FindVersion(GitVersionContext context)
        {
            var versionOnMasterFinder = new VersionOnMasterFinder();
            var tip = context.CurrentCommit;
            var versionFromMaster = versionOnMasterFinder.Execute(context, tip.When());

            var f = new CommitFilter
            {
                Since = tip,
                Until = context.Repository.FindBranch("master").Tip,
                SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time
            };

            var c = context.Repository.Commits.QueryBy(f);
            var numberOfCommitsSinceRelease = c.Count();

            var semanticVersion = new SemanticVersion
            {
                Major = versionFromMaster.Major,
                Minor = versionFromMaster.Minor + 1,
                Patch = 0,
                PreReleaseTag = context.Configuration.DevelopBranchTag + numberOfCommitsSinceRelease,
                BuildMetaData = new SemanticVersionBuildMetaData(numberOfCommitsSinceRelease, context.CurrentBranch.Name,tip.Sha,tip.When()),
            };

            semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository, context.Configuration);

            return semanticVersion;
        }
开发者ID:unic,项目名称:GitVersion,代码行数:29,代码来源:DevelopVersionFinder.cs


示例4: GetVersion

    public static Tuple<CachedVersion, GitVersionContext> GetVersion(string gitDirectory, Config configuration)
    {
        using (var repo = RepositoryLoader.GetRepo(gitDirectory))
        {
            var versionFinder = new GitVersionFinder();
            var context = new GitVersionContext(repo, configuration);
            var ticks = DirectoryDateFinder.GetLastDirectoryWrite(gitDirectory);
            var key = string.Format("{0}:{1}:{2}", repo.Head.CanonicalName, repo.Head.Tip.Sha, ticks);

            Tuple<CachedVersion, GitVersionContext> result;
            if (versionCacheVersions.TryGetValue(key, out result))
            {
                if (result.Item1.Timestamp != ticks)
                {
                    Logger.WriteInfo("Change detected. flushing cache.");
                    result.Item1.SemanticVersion = versionFinder.FindVersion(context);
                }
                return result;
            }
            Logger.WriteInfo("Version not in cache. Calculating version.");

            return versionCacheVersions[key] = Tuple.Create(new CachedVersion
            {
                SemanticVersion = versionFinder.FindVersion(context),
                Timestamp = ticks
            }, context);
        }
    }
开发者ID:Wikell,项目名称:GitVersion,代码行数:28,代码来源:VersionCache.cs


示例5: GetVersion

    public static CachedVersion GetVersion(string gitDirectory, Config configuration)
    {
        using (var repo = RepositoryLoader.GetRepo(gitDirectory))
        {
            var versionFinder = new GitVersionFinder();
            var context = new GitVersionContext(repo, configuration);
            var ticks = DirectoryDateFinder.GetLastDirectoryWrite(gitDirectory);
            var key = string.Format("{0}:{1}:{2}", repo.Head.CanonicalName, repo.Head.Tip.Sha, ticks);
            CachedVersion cachedVersion;
            if (versionCacheVersions.TryGetValue(key, out cachedVersion))
            {
                if (cachedVersion.Timestamp != ticks)
                {
                    Logger.WriteInfo("Change detected. flushing cache.");
                    cachedVersion.SemanticVersion = versionFinder.FindVersion(context);
                    cachedVersion.MasterReleaseDate = LastMinorVersionFinder.Execute(repo, new Config(), repo.Head.Tip);
                }
                return cachedVersion;
            }
            Logger.WriteInfo("Version not in cache. Calculating version.");

            return versionCacheVersions[key] = new CachedVersion
            {
                SemanticVersion = versionFinder.FindVersion(context),
                MasterReleaseDate = LastMinorVersionFinder.Execute(repo, new Config(), repo.Head.Tip),
                Timestamp = ticks
            };

        }
    }
开发者ID:unic,项目名称:GitVersion,代码行数:30,代码来源:VersionCache.cs


示例6: UsesBranchSpecificConfigOverTopLevelDefaults

 public void UsesBranchSpecificConfigOverTopLevelDefaults()
 {
     var config = new Config
     {
         VersioningMode = VersioningMode.ContinuousDelivery,
         Branches =
         {
             {
                 "dev(elop)?(ment)?$", new BranchConfig
                 {
                     VersioningMode = VersioningMode.ContinuousDeployment,
                     Tag = "alpha"
                 }
             }
         }
     };
     ConfigurationProvider.ApplyDefaultsTo(config);
     var develop = new MockBranch("develop") { new MockCommit { CommitterEx = Constants.SignatureNow() } };
     var mockRepository = new MockRepository
     {
         Branches = new MockBranchCollection
         {
             new MockBranch("master") { new MockCommit { CommitterEx = Constants.SignatureNow() } },
             develop
         }
     };
     var context = new GitVersionContext(mockRepository, develop, config);
     context.Configuration.Tag.ShouldBe("alpha");
 }
开发者ID:pierrebakker,项目名称:GitVersion,代码行数:29,代码来源:GitVersionContextTests.cs


示例7: ExtractIssueNumber

        // TODO refactor to remove duplication
        string ExtractIssueNumber(GitVersionContext context)
        {
            const string prefix = "/pull/";
            var pullRequestBranch = context.CurrentBranch;

            var start = pullRequestBranch.CanonicalName.IndexOf(prefix, StringComparison.Ordinal);
            var end = pullRequestBranch.CanonicalName.LastIndexOf("/merge", pullRequestBranch.CanonicalName.Length - 1,
                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))
            {
                var message = string.Format("Unable to extract pull request number from '{0}'.", pullRequestBranch.CanonicalName);
                throw new WarningException(message);
            }

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


示例8: DetermineIncrementedField

        public static VersionField? DetermineIncrementedField(GitVersionContext context, BaseVersion baseVersion)
        {
            var commitMessageIncrement = FindCommitMessageIncrement(context, baseVersion);
            var defaultIncrement = context.Configuration.Increment.ToVersionField();

            // use the default branch config increment strategy if there are no commit message overrides
            if (commitMessageIncrement == null)
            {
                return baseVersion.ShouldIncrement ? defaultIncrement : (VersionField?)null;
            }

            // cap the commit message severity to minor for alpha versions
            if (baseVersion.SemanticVersion < new SemanticVersion(1) && commitMessageIncrement > VersionField.Minor)
            {
                commitMessageIncrement = VersionField.Minor;
            }

            // don't increment for less than the branch config increment, if the absence of commit messages would have
            // still resulted in an increment of configuration.Increment
            if (baseVersion.ShouldIncrement && commitMessageIncrement < defaultIncrement)
            {
                return defaultIncrement;
            }

            return commitMessageIncrement;
        }
开发者ID:asbjornu,项目名称:GitVersion,代码行数:26,代码来源:IncrementStrategyFinder.cs


示例9: FindVersion

        public SemanticVersion FindVersion(GitVersionContext context)
        {
            var versionOnMasterFinder = new VersionOnMasterFinder();
            var tip = context.CurrentBranch.Tip;
            var versionFromMaster = versionOnMasterFinder.Execute(context, tip.When());

            var f = new CommitFilter
            {
                Since = tip,
                Until = context.Repository.FindBranch("master").Tip,
                SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time
            };

            var c = context.Repository.Commits.QueryBy(f);
            var numberOfCommitsSinceRelease = c.Count();

            var releaseDate = ReleaseDateFinder.Execute(context.Repository, tip.Sha, 0);
            var semanticVersion = new SemanticVersion
            {
                Major = versionFromMaster.Major,
                Minor = versionFromMaster.Minor + 1,
                Patch = 0,
                PreReleaseTag = "unstable" + numberOfCommitsSinceRelease,
                BuildMetaData = new SemanticVersionBuildMetaData(numberOfCommitsSinceRelease, context.CurrentBranch.Name, releaseDate),
            };
            return semanticVersion;
        }
开发者ID:potherca-contrib,项目名称:GitVersion,代码行数:27,代码来源:DevelopVersionFinder.cs


示例10: GetBranchConfiguration

        /// <summary>
        /// Gets the <see cref="BranchConfig"/> for the current commit.
        /// </summary>
        public static BranchConfig GetBranchConfiguration(GitVersionContext context, Branch targetBranch, IList<Branch> excludedInheritBranches = null)
        {
            var matchingBranches = LookupBranchConfiguration(context.FullConfiguration, targetBranch).ToArray();

            BranchConfig branchConfiguration;
            if (matchingBranches.Length > 0)
            {
                branchConfiguration = matchingBranches[0];

                if (matchingBranches.Length > 1)
                {
                    Logger.WriteWarning(string.Format(
                        "Multiple branch configurations match the current branch branchName of '{0}'. Using the first matching configuration, '{1}'. Matching configurations include: '{2}'",
                        targetBranch.FriendlyName,
                        branchConfiguration.Name,
                        string.Join("', '", matchingBranches.Select(b => b.Name))));
                }
            }
            else
            {
                Logger.WriteInfo(string.Format(
                    "No branch configuration found for branch {0}, falling back to default configuration",
                    targetBranch.FriendlyName));

                branchConfiguration = new BranchConfig { Name = string.Empty };
                ConfigurationProvider.ApplyBranchDefaults(context.FullConfiguration, branchConfiguration, "");
            }

            return branchConfiguration.Increment == IncrementStrategy.Inherit ?
                InheritBranchConfiguration(context, targetBranch, branchConfiguration, excludedInheritBranches) :
                branchConfiguration;
        }
开发者ID:GitTools,项目名称:GitVersion,代码行数:35,代码来源:BranchConfigurationCalculator.cs


示例11: FindVersion

        protected SemanticVersion FindVersion(
            GitVersionContext context,
            BranchType branchType)
        {
            var ancestor = FindCommonAncestorWithDevelop(context.Repository, context.CurrentBranch, branchType);

            if (!IsThereAnyCommitOnTheBranch(context.Repository, context.CurrentBranch))
            {
                var developVersionFinder = new DevelopVersionFinder();
                return developVersionFinder.FindVersion(context);
            }

            var versionOnMasterFinder = new VersionOnMasterFinder();
            var versionFromMaster = versionOnMasterFinder.Execute(context, context.CurrentBranch.Tip.Committer.When);

            var numberOfCommitsOnBranchSinceCommit = NumberOfCommitsOnBranchSinceCommit(context, ancestor);
            var sha = context.CurrentBranch.Tip.Sha;
            var releaseDate = ReleaseDateFinder.Execute(context.Repository, sha, 0);
            var semanticVersion = new SemanticVersion
            {
                Major = versionFromMaster.Major,
                Minor = versionFromMaster.Minor + 1,
                Patch = 0,
                PreReleaseTag = "unstable0",
                BuildMetaData = new SemanticVersionBuildMetaData(
                    numberOfCommitsOnBranchSinceCommit,
                    context.CurrentBranch.Name, releaseDate)
            };

            return semanticVersion;
        }
开发者ID:potherca-contrib,项目名称:GitVersion,代码行数:31,代码来源:DevelopBasedVersionFinderBase.cs


示例12: GetSemanticVersion

 static SemanticVersion GetSemanticVersion(Repository repository)
 {
     var versionForRepositoryFinder = new GitVersionFinder();
     var gitVersionContext = new GitVersionContext(repository);
     Logger.WriteInfo("Running against branch: " + gitVersionContext.CurrentBranch.Name);
     return versionForRepositoryFinder.FindVersion(gitVersionContext);
 }
开发者ID:hbre,项目名称:GitVersion,代码行数:7,代码来源:VersionCache.cs


示例13: FindCommitMessageIncrement

        private static VersionField? FindCommitMessageIncrement(GitVersionContext context, BaseVersion baseVersion)
        {
            if (context.Configuration.CommitMessageIncrementing == CommitMessageIncrementMode.Disabled)
            {
                return null;
            }

            var commits = GetIntermediateCommits(context.Repository, baseVersion.BaseVersionSource, context.CurrentCommit);

            if (context.Configuration.CommitMessageIncrementing == CommitMessageIncrementMode.MergeMessageOnly)
            {
                commits = commits.Where(c => c.Parents.Count() > 1);
            }

            var majorRegex = CreateRegex(context.Configuration.MajorVersionBumpMessage ?? DefaultMajorPattern);
            var minorRegex = CreateRegex(context.Configuration.MinorVersionBumpMessage ?? DefaultMinorPattern);
            var patchRegex = CreateRegex(context.Configuration.PatchVersionBumpMessage ?? DefaultPatchPattern);

            var increments = commits
                .Select(c => FindIncrementFromMessage(c.Message, majorRegex, minorRegex, patchRegex))
                .Where(v => v != null)
                .Select(v => v.Value)
                .ToList();

            if (increments.Any())
            {
                return increments.Max();
            }

            return null;
        }
开发者ID:onovotny,项目名称:GitVersion,代码行数:31,代码来源:IncrementStrategyFinder.cs


示例14: FindVersion

        protected SemanticVersion FindVersion(
            GitVersionContext context,
            BranchType branchType)
        {
            var ancestor = FindCommonAncestorWithDevelop(context.Repository, context.CurrentBranch, branchType);

            if (!IsThereAnyCommitOnTheBranch(context.Repository, context.CurrentBranch))
            {
                var developVersionFinder = new DevelopVersionFinder();
                return developVersionFinder.FindVersion(context);
            }

            var versionOnMasterFinder = new VersionOnMasterFinder();
            var versionFromMaster = versionOnMasterFinder.Execute(context, context.CurrentCommit.When());

            var numberOfCommitsOnBranchSinceCommit = NumberOfCommitsOnBranchSinceCommit(context, ancestor);
            var preReleaseTag = context.CurrentBranch.Name
                .TrimStart(branchType.ToString() + '-')
                .TrimStart(branchType.ToString() + '/');
            var semanticVersion = new SemanticVersion
            {
                Major = versionFromMaster.Major,
                Minor = versionFromMaster.Minor + 1,
                Patch = 0,
                PreReleaseTag = preReleaseTag,
                BuildMetaData = new SemanticVersionBuildMetaData(
                    numberOfCommitsOnBranchSinceCommit,
                    context.CurrentBranch.Name, context.CurrentCommit.Sha, context.CurrentCommit.When())
            };

            semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository, context.Configuration);

            return semanticVersion;
        }
开发者ID:unic,项目名称:GitVersion,代码行数:34,代码来源:DevelopBasedVersionFinderBase.cs


示例15: ExecuteGitVersion

        public static VersionVariables ExecuteGitVersion(IFileSystem fileSystem, string targetUrl, string dynamicRepositoryLocation, Authentication authentication, string targetBranch, bool noFetch, string workingDirectory, string commitId)
        {
            // Normalise if we are running on build server
            var gitPreparer = new GitPreparer(targetUrl, dynamicRepositoryLocation, authentication, noFetch, workingDirectory);
            var applicableBuildServers = BuildServerList.GetApplicableBuildServers();
            var buildServer = applicableBuildServers.FirstOrDefault();
            var currentBranch = buildServer == null ? null : buildServer.GetCurrentBranch();
            if (!string.IsNullOrEmpty(currentBranch))
            {
                Logger.WriteInfo("Branch from build environment: " + currentBranch);
            }
            gitPreparer.Initialise(buildServer != null, currentBranch ?? targetBranch);
            var dotGitDirectory = gitPreparer.GetDotGitDirectory();
            var projectRoot = gitPreparer.GetProjectRootDirectory();
            Logger.WriteInfo(string.Format("Project root is: " + projectRoot));
            if (string.IsNullOrEmpty(dotGitDirectory) || string.IsNullOrEmpty(projectRoot))
            {
                // TODO Link to wiki article
                throw new Exception(string.Format("Failed to prepare or find the .git directory in path '{0}'.", workingDirectory));
            }
            VersionVariables variables;
            var versionFinder = new GitVersionFinder();
            var configuration = ConfigurationProvider.Provide(projectRoot, fileSystem);

            using (var repo = RepositoryLoader.GetRepo(dotGitDirectory))
            {
                var gitVersionContext = new GitVersionContext(repo, configuration, commitId: commitId);
                var semanticVersion = versionFinder.FindVersion(gitVersionContext);
                var config = gitVersionContext.Configuration;
                variables = VariableProvider.GetVariablesFor(semanticVersion, config.AssemblyVersioningScheme, config.VersioningMode, config.ContinuousDeploymentFallbackTag, gitVersionContext.IsCurrentCommitTagged);
            }

            return variables;
        }
开发者ID:niing,项目名称:GitVersion,代码行数:34,代码来源:ExecuteCore.cs


示例16: EnsureHeadIsNotDetached

        void EnsureHeadIsNotDetached(GitVersionContext context)
        {
            if (!context.CurrentBranch.IsDetachedHead())
            {
                return;
            }

            var message = string.Format("It looks like the branch being examined is a detached Head pointing to commit '{0}'. Without a proper branch name GitVersion cannot determine the build version.", context.CurrentCommit.Id.ToString(7));
            throw new WarningException(message);
        }
开发者ID:nakioman,项目名称:GitVersion,代码行数:10,代码来源:GitVersionFinder.cs


示例17: EnsureHeadIsNotDetached

        void EnsureHeadIsNotDetached(GitVersionContext context)
        {
            if (!context.CurrentBranch.CanonicalName.Equals("(no branch)", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var message = string.Format("It looks like the branch being examined is a detached Head pointing to commit '{0}'. Without a proper branch name GitVersion cannot determine the build version.", context.CurrentBranch.Tip.Id.ToString(7));
            throw new ErrorException(message);
        }
开发者ID:potherca-contrib,项目名称:GitVersion,代码行数:10,代码来源:GitVersionFinder.cs


示例18: FindVersion

 public SemanticVersion FindVersion(GitVersionContext context)
 {
     try
     {
         return FindVersion(context, BranchType.Unknown, "master");
     }
     catch (Exception)
     {
         return new SemanticVersion();
     }
 }
开发者ID:hbre,项目名称:GitVersion,代码行数:11,代码来源:OtherBranchVersionFinder.cs


示例19: NumberOfCommitsOnBranchSinceCommit

        int NumberOfCommitsOnBranchSinceCommit(GitVersionContext context, Commit commit)
        {
            var qf = new CommitFilter
            {
                Since = context.CurrentCommit,
                Until = commit,
                SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Time
            };

            return context.Repository.Commits.QueryBy(qf).Count();
        }
开发者ID:hbre,项目名称:GitVersion,代码行数:11,代码来源:BuildNumberCalculator.cs


示例20: NextSemverCalculator

 public NextSemverCalculator(
     NextVersionTxtFileFinder nextVersionTxtFileFinder,
     LastTaggedReleaseFinder lastTaggedReleaseFinder,
     GitVersionContext context)
 {
     this.nextVersionTxtFileFinder = nextVersionTxtFileFinder;
     this.lastTaggedReleaseFinder = lastTaggedReleaseFinder;
     mergedBranchesWithVersionFinder = new MergedBranchesWithVersionFinder(context);
     unknownBranchFinder = new OtherBranchVersionFinder();
     this.context = context;
 }
开发者ID:potherca-contrib,项目名称:GitVersion,代码行数:11,代码来源:NextSemverCalculator.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Glade.XML类代码示例发布时间:2022-05-26
下一篇:
C# GitUIPluginInterfaces.GitUIBaseEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap