本文整理汇总了C#中RepositoryBrowser.GetCommits方法的典型用法代码示例。如果您正苦于以下问题:C# RepositoryBrowser.GetCommits方法的具体用法?C# RepositoryBrowser.GetCommits怎么用?C# RepositoryBrowser.GetCommits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RepositoryBrowser
的用法示例。
在下文中一共展示了RepositoryBrowser.GetCommits方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LastedCommit
public ActionResult LastedCommit(int page = 1)
{
page = page >= 1 ? page : 1;
int pageSize = 10;
var di = new DirectoryInfo(UserConfiguration.Current.Repositories);
var allRepo = di.GetDirectories("*.*", SearchOption.TopDirectoryOnly);
var list = new List<ActivityCommitModels>();
var repoList = this.GetIndexModel();
foreach (var repoPath in allRepo)
{
using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, repoPath.Name)))
{
var name = PathEncoder.Decode("");
string referenceName;
int totalCount;
var commits = browser.GetCommits(name, 1, 10, out referenceName, out totalCount).ToList();
if (commits.Count < 1)
continue;
var com = commits.OrderByDescending(c => c.Date).FirstOrDefault();
var id = com.ID;
var committer = com.Author;
var committMail = com.AuthorEmail;
var committWhen = com.Date;
var message = com.Message;
if (repoList.Where(r => r.Name == repoPath.Name).FirstOrDefault() == null)
continue;
var repoGuid = repoList.Where(r => r.Name == repoPath.Name).FirstOrDefault().Id;
var ac = new ActivityCommitModels();
ac.ProjectName = repoPath.Name;
ac.CommitterName = committer;
ac.Email = committMail;
ac.When = committWhen;
ac.Message = message;
ac.idSha = id;
ac.id = repoGuid;
list.Add(ac);
}
}
ViewBag.TotalCount = list.Count;
var sortList = list.OrderByDescending(c => c.When).ToList();
if (page >= 1 && pageSize >= 1)
{
sortList = sortList.Skip((page - 1) * pageSize).Take(pageSize).ToList();
}
return View(sortList);
}
示例2: Commits
public ActionResult Commits(string id, string name)
{
ViewBag.ID = id;
if (!String.IsNullOrEmpty(id))
{
using (var browser = new RepositoryBrowser(Path.Combine(UserConfigurationManager.Repositories, id)))
{
string currentBranchName;
var commits = browser.GetCommits(name, out currentBranchName);
PopulateBranchesData(browser, currentBranchName);
return View(new RepositoryCommitsModel { Commits = commits, Name = id });
}
}
return View();
}
示例3: Commits
public ActionResult Commits(string id, string encodedName)
{
ViewBag.ID = id;
ViewBag.ShowShortMessageOnly = true;
if (!String.IsNullOrEmpty(id))
{
using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
{
var name = PathEncoder.Decode(encodedName);
string referenceName;
var commits = browser.GetCommits(name, out referenceName);
PopulateBranchesData(browser, referenceName);
return View(new RepositoryCommitsModel { Commits = commits, Name = id });
}
}
return View();
}
示例4: Commits
public ActionResult Commits(Guid id, string encodedName, int page = 1)
{
page = page >= 1 ? page : 1;
ViewBag.ID = id;
ViewBag.ShowShortMessageOnly = true;
var repo = RepositoryRepository.GetRepository(id);
using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, repo.Name)))
{
var name = PathEncoder.Decode(encodedName);
string referenceName;
int totalCount;
var commits = browser.GetCommits(name, page, 10, out referenceName, out totalCount);
PopulateBranchesData(browser, referenceName);
ViewBag.TotalCount = totalCount;
var linksreg = repo.LinksUseGlobal ? UserConfiguration.Current.LinksRegex : repo.LinksRegex;
var linksurl = repo.LinksUseGlobal ? UserConfiguration.Current.LinksUrl : repo.LinksUrl;
foreach (var commit in commits)
{
var links = new List<string>();
if (!string.IsNullOrEmpty(linksreg))
{
try
{
var matches = Regex.Matches(commit.Message, linksreg);
if (matches.Count > 0)
{
foreach (Match match in matches)
{
IEnumerable<Group> groups = match.Groups.Cast<Group>();
var link = "";
try
{
var m = groups.Select(x => x.ToString()).ToArray();
link = string.Format(linksurl, m);
}
catch (FormatException e)
{
link = "An error occured while trying to format the link. Exception: " + e.Message;
}
links.Add(link);
}
}
}
catch (ArgumentException e)
{
links.Add("An error occured while trying to match the regualar expression. Error: " + e.Message);
}
}
commit.Links = links;
}
return View(new RepositoryCommitsModel {
Commits = commits,
Name = repo.Name,
Logo = new RepositoryLogoDetailModel(repo.Logo)
});
}
}