Ejemplo n.º 1
0
        public ActionResult ViewCommits(string repo, string @object = null, int page = 1)
        {
            var resourceInfo = this.FileManager.GetResourceInfo(repo);

            if (resourceInfo.Type != ResourceType.Directory || page < 1)
            {
                return(HttpNotFound());
            }

            const int PageSize = 20;
            int       skip     = PageSize * (page - 1);
            var       count    = GitUtilities.CountCommits(resourceInfo.FullPath, @object);

            if (skip >= count)
            {
                return(HttpNotFound());
            }

            AddRepoBreadCrumb(repo);
            this.BreadCrumbs.Append("Browse", "ViewCommits", "Commit Log", new { repo, @object });

            var commits  = GitUtilities.GetLogEntries(resourceInfo.FullPath, PageSize, skip, @object);
            var branches = GitUtilities.GetAllRefs(resourceInfo.FullPath).Where(r => r.RefType == RefType.Branch).ToList();

            ViewBag.PaginationInfo = new PaginationInfo(page, (count + PageSize - 1) / PageSize, "Browse", "ViewCommits", new { repo });
            ViewBag.RepoName       = resourceInfo.Name;
            ViewBag.Object         = @object ?? "HEAD";
            ViewBag.Branches       = branches;

            return(View(commits));
        }
Ejemplo n.º 2
0
        public ActionResult ViewGraph(string repo, int page = 1)
        {
            var resourceInfo = this.FileManager.GetResourceInfo(repo);

            if (resourceInfo.Type != ResourceType.Directory || page < 1)
            {
                return(HttpNotFound());
            }

            const int PageSize = 50;
            int       skip     = PageSize * (page - 1);
            var       count    = GitUtilities.CountCommits(resourceInfo.FullPath, allRefs: true);

            if (skip >= count)
            {
                return(HttpNotFound());
            }

            this.BreadCrumbs.Append("Browse", "Index", "Browse");
            AddRepoBreadCrumb(repo);
            this.BreadCrumbs.Append("Graph", "ViewGraph", "View Graph", new { repo });

            var commits = GetLogEntries(resourceInfo.FullPath, skip + PageSize).Skip(skip).ToList();

            ViewBag.PaginationInfo = new PaginationInfo(page, (count + PageSize - 1) / PageSize, "Graph", "ViewGraph", new { repo });
            ViewBag.RepoName       = resourceInfo.Name;

            return(View(commits));
        }