本文整理汇总了C#中NGit.ObjectId.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectId.GetName方法的具体用法?C# ObjectId.GetName怎么用?C# ObjectId.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NGit.ObjectId
的用法示例。
在下文中一共展示了ObjectId.GetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertReflog
/// <exception cref="System.IO.IOException"></exception>
private void AssertReflog(ObjectId prevHead, ObjectId head)
{
// Check the reflog for HEAD
string actualHeadMessage = db.GetReflogReader(Constants.HEAD).GetLastEntry().GetComment
();
string expectedHeadMessage = head.GetName() + ": updating HEAD";
NUnit.Framework.Assert.AreEqual(expectedHeadMessage, actualHeadMessage);
NUnit.Framework.Assert.AreEqual(head.GetName(), db.GetReflogReader(Constants.HEAD
).GetLastEntry().GetNewId().GetName());
NUnit.Framework.Assert.AreEqual(prevHead.GetName(), db.GetReflogReader(Constants.
HEAD).GetLastEntry().GetOldId().GetName());
// The reflog for master contains the same as the one for HEAD
string actualMasterMessage = db.GetReflogReader("refs/heads/master").GetLastEntry
().GetComment();
string expectedMasterMessage = head.GetName() + ": updating HEAD";
// yes!
NUnit.Framework.Assert.AreEqual(expectedMasterMessage, actualMasterMessage);
NUnit.Framework.Assert.AreEqual(head.GetName(), db.GetReflogReader(Constants.HEAD
).GetLastEntry().GetNewId().GetName());
NUnit.Framework.Assert.AreEqual(prevHead.GetName(), db.GetReflogReader("refs/heads/master"
).GetLastEntry().GetOldId().GetName());
}
示例2: InsertId
/// <summary>Find the right place to insert a Change-Id and return it.</summary>
/// <remarks>
/// Find the right place to insert a Change-Id and return it.
/// <p/>
/// If no Change-Id is found the Change-Id is inserted before
/// the first footer line but after a Bug line.
/// If Change-Id is found and replaceExisting is set to false,
/// the message is unchanged.
/// If Change-Id is found and replaceExisting is set to true,
/// the Change-Id is replaced with
/// <code>changeId</code>
/// .
/// </remarks>
/// <param name="message"></param>
/// <param name="changeId"></param>
/// <param name="replaceExisting"></param>
/// <returns>a commit message with an inserted Change-Id line</returns>
public static string InsertId(string message, ObjectId changeId, bool replaceExisting
)
{
if (message.IndexOf(CHANGE_ID) > 0)
{
if (replaceExisting)
{
int i = message.IndexOf(CHANGE_ID) + 10;
while (message[i] == ' ')
{
i++;
}
string oldId = message.Length == (i + 40) ? Sharpen.Runtime.Substring(message, i)
: Sharpen.Runtime.Substring(message, i, i + 41);
message = message.Replace(oldId, "I" + changeId.GetName());
}
return message;
}
string[] lines = message.Split("\n");
int footerFirstLine = lines.Length;
for (int i_1 = lines.Length - 1; i_1 > 1; --i_1)
{
if (footerPattern.Matcher(lines[i_1]).Matches())
{
footerFirstLine = i_1;
continue;
}
if (footerFirstLine != lines.Length && lines[i_1].Length == 0)
{
break;
}
if (footerFirstLine != lines.Length && includeInFooterPattern.Matcher(lines[i_1])
.Matches())
{
footerFirstLine = i_1 + 1;
continue;
}
footerFirstLine = lines.Length;
break;
}
int insertAfter = footerFirstLine;
for (int i_2 = footerFirstLine; i_2 < lines.Length; ++i_2)
{
if (issuePattern.Matcher(lines[i_2]).Matches())
{
insertAfter = i_2 + 1;
continue;
}
break;
}
StringBuilder ret = new StringBuilder();
int i_3 = 0;
for (; i_3 < insertAfter; ++i_3)
{
ret.Append(lines[i_3]);
ret.Append("\n");
}
if (insertAfter == lines.Length && insertAfter == footerFirstLine)
{
ret.Append("\n");
}
ret.Append(CHANGE_ID);
ret.Append(" I");
ret.Append(ObjectId.ToString(changeId));
ret.Append("\n");
for (; i_3 < lines.Length; ++i_3)
{
ret.Append(lines[i_3]);
ret.Append("\n");
}
return ret.ToString();
}