本文整理汇总了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));
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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];
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例13: GetVersions
public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
{
if (context.Configuration.IsCurrentBranchDevelop)
{
return ReleaseBranchBaseVersions(context).Union(MasterTagsVersions(context));
}
return new BaseVersion[0];
}
示例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;
}
示例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;
}