本文整理匯總了C#中NGit.Api.Git.Blame方法的典型用法代碼示例。如果您正苦於以下問題:C# Git.Blame方法的具體用法?C# Git.Blame怎麽用?C# Git.Blame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NGit.Api.Git
的用法示例。
在下文中一共展示了Git.Blame方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetAnnotations
public override Annotation[] GetAnnotations (FilePath repositoryPath)
{
var repository = GetRepository (repositoryPath);
RevCommit hc = GetHeadCommit (repository);
if (hc == null)
return new Annotation [0];
var git = new NGit.Api.Git (repository);
var result = git.Blame ().SetFollowFileRenames (true).SetFilePath (repository.ToGitPath (repositoryPath)).Call ();
result.ComputeAll ();
List<Annotation> list = new List<Annotation> ();
for (int i = 0; i < result.GetResultContents ().Size (); i++) {
var commit = result.GetSourceCommit (i);
var author = result.GetSourceAuthor (i);
if (commit != null && author != null) {
string name = string.Format ("{0} <{1}>", author.GetName (), author.GetEmailAddress ());
var commitTime = new DateTime (1970, 1, 1).AddSeconds (commit.CommitTime);
list.Add (new Annotation (commit.Name, name, commitTime));
} else {
list.Add (new Annotation (new string ('0', 20), "<uncommitted>", DateTime.Now));
}
}
return list.ToArray ();
}