本文整理汇总了C#中Branch.IsDetachedHead方法的典型用法代码示例。如果您正苦于以下问题:C# Branch.IsDetachedHead方法的具体用法?C# Branch.IsDetachedHead怎么用?C# Branch.IsDetachedHead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Branch
的用法示例。
在下文中一共展示了Branch.IsDetachedHead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GitVersionContext
public GitVersionContext(IRepository repository, Branch currentBranch, Config configuration, bool onlyEvaluateTrackedBranches = true, string commitId = null)
{
Repository = repository;
RepositoryMetadataProvider = new GitRepoMetadataProvider(repository);
FullConfiguration = configuration;
OnlyEvaluateTrackedBranches = onlyEvaluateTrackedBranches;
if (currentBranch == null)
throw new InvalidOperationException("Need a branch to operate on");
if (!string.IsNullOrWhiteSpace(commitId))
{
Logger.WriteInfo(string.Format("Searching for specific commit '{0}'", commitId));
var commit = repository.Commits.FirstOrDefault(c => string.Equals(c.Sha, commitId, StringComparison.OrdinalIgnoreCase));
if (commit != null)
{
CurrentCommit = commit;
}
else
{
Logger.WriteWarning(string.Format("Commit '{0}' specified but not found", commitId));
}
}
if (CurrentCommit == null)
{
Logger.WriteInfo("Using latest commit on specified branch");
CurrentCommit = currentBranch.Tip;
}
if (currentBranch.IsDetachedHead())
{
CurrentBranch = RepositoryMetadataProvider.GetBranchesContainingCommit(CurrentCommit, repository.Branches.ToList(), OnlyEvaluateTrackedBranches).OnlyOrDefault() ?? currentBranch;
}
else
{
CurrentBranch = currentBranch;
}
CalculateEffectiveConfiguration();
CurrentCommitTaggedVersion = repository.Tags
.SelectMany(t =>
{
SemanticVersion version;
if (t.PeeledTarget() == CurrentCommit && SemanticVersion.TryParse(t.FriendlyName, Configuration.GitTagPrefix, out version))
return new[] { version };
return new SemanticVersion[0];
})
.Max();
IsCurrentCommitTagged = CurrentCommitTaggedVersion != null;
}
示例2: GitVersionContext
public GitVersionContext(IRepository repository, Branch currentBranch)
{
Repository = repository;
if (currentBranch == null)
return;
CurrentCommit = currentBranch.Tip;
if (repository != null && currentBranch.IsDetachedHead())
{
CurrentBranch = GetBranchesContainingCommit(CurrentCommit.Sha).OnlyOrDefault() ?? currentBranch;
}
else
{
CurrentBranch = currentBranch;
}
}