本文整理汇总了C#中Ref.GetLeaf方法的典型用法代码示例。如果您正苦于以下问题:C# Ref.GetLeaf方法的具体用法?C# Ref.GetLeaf怎么用?C# Ref.GetLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ref
的用法示例。
在下文中一共展示了Ref.GetLeaf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
/// <summary>Construct the merge commit message.</summary>
/// <remarks>Construct the merge commit message.</remarks>
/// <param name="refsToMerge">the refs which will be merged</param>
/// <param name="target">the branch ref which will be merged into</param>
/// <returns>merge commit message</returns>
public virtual string Format(IList<Ref> refsToMerge, Ref target)
{
StringBuilder sb = new StringBuilder();
sb.Append("Merge ");
IList<string> branches = new AList<string>();
IList<string> remoteBranches = new AList<string>();
IList<string> tags = new AList<string>();
IList<string> commits = new AList<string>();
IList<string> others = new AList<string>();
foreach (Ref @ref in refsToMerge)
{
if (@ref.GetName().StartsWith(Constants.R_HEADS))
{
branches.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().StartsWith(Constants.R_REMOTES))
{
remoteBranches.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().StartsWith(Constants.R_TAGS))
{
tags.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().Equals(@ref.GetObjectId().GetName()))
{
commits.AddItem("'" + @ref.GetName() + "'");
}
else
{
others.AddItem(@ref.GetName());
}
}
}
}
}
IList<string> listings = new AList<string>();
if (!branches.IsEmpty())
{
listings.AddItem(JoinNames(branches, "branch", "branches"));
}
if (!remoteBranches.IsEmpty())
{
listings.AddItem(JoinNames(remoteBranches, "remote branch", "remote branches"));
}
if (!tags.IsEmpty())
{
listings.AddItem(JoinNames(tags, "tag", "tags"));
}
if (!commits.IsEmpty())
{
listings.AddItem(JoinNames(commits, "commit", "commits"));
}
if (!others.IsEmpty())
{
listings.AddItem(StringUtils.Join(others, ", ", " and "));
}
sb.Append(StringUtils.Join(listings, ", "));
string targetName = target.GetLeaf().GetName();
if (!targetName.Equals(Constants.R_HEADS + Constants.MASTER))
{
string targetShortName = Repository.ShortenRefName(target.GetName());
sb.Append(" into " + targetShortName);
}
return sb.ToString();
}