当前位置: 首页>>代码示例>>C#>>正文


C# RepositoryBrowser.GetCommits方法代码示例

本文整理汇总了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);
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:59,代码来源:ActivityController.cs

示例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();
        }
开发者ID:randome,项目名称:Bonobo-Git-Server,代码行数:16,代码来源:RepositoryController.cs

示例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();
        }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:18,代码来源:RepositoryController.cs

示例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)
                });
            }
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:59,代码来源:RepositoryController.cs


注:本文中的RepositoryBrowser.GetCommits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。