本文整理汇总了C#中LibGit2Sharp.Repository.GetRevisions方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.GetRevisions方法的具体用法?C# Repository.GetRevisions怎么用?C# Repository.GetRevisions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibGit2Sharp.Repository
的用法示例。
在下文中一共展示了Repository.GetRevisions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public async Task<object> Get(string id)
{
using (var ctx = new ReviewContext())
{
var review = await ctx.Reviews.FindAsync(id);
if (review == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
List<Revision> revisions;
var commits = new HashSet<Commit>();
using (var repo = new Repository(GitReviewApplication.RepositoryPath))
{
revisions = repo.GetRevisions(review.RefPrefix).ToList();
var mergeBases = new Dictionary<Revision, HashSet<Commit>>(revisions.Count);
var ignored = new Dictionary<Revision, HashSet<Commit>>(revisions.Count);
foreach (var rev in revisions)
{
var revReachable = new HashSet<Commit>();
var revMergeBases = new HashSet<Commit>();
var revIgnored = new HashSet<Commit>();
var sourceCommit = (Commit)rev.Source.Target;
var destinationCommit = (Commit)rev.Destination.Target;
GetMergeDetails(repo, sourceCommit, destinationCommit, out revReachable, out revMergeBases, out revIgnored);
ignored[rev] = revIgnored;
mergeBases[rev] = revMergeBases;
commits.UnionWith(revReachable);
}
return new
{
Review = new
{
Id = review.Id,
Revisions = revisions.Select(r => review.Id + ":" + r.Id)
},
Revisions = revisions.Select(r => new
{
Id = review.Id + ":" + r.Id,
Source = r.Source.TargetIdentifier,
Destination = r.Destination.TargetIdentifier,
MergeBases = mergeBases[r].Select(b => b.Sha).ToList(),
Ignored = ignored[r].Select(i => i.Sha).ToList(),
}).ToList(),
Commits = commits.Select(c => new
{
Id = c.Sha,
Author = c.Author.Email,
AuthoredAt = c.Author.When,
Committer = c.Committer.Email,
CommittedAt = c.Committer.When,
Message = c.Message,
Parents = c.Parents.Select(p => p.Sha).ToList(),
}).ToList(),
};
}
}
}