Exemplo n.º 1
0
        public ActionResult ManageRepo(string repoName, RepoSettings settings)
        {
            var resourceInfo = this.FileManager.GetResourceInfo(repoName);

            if (resourceInfo.Type != ResourceType.Directory)
            {
                return(HttpNotFound());
            }

            var repo = GitUtilities.GetRepoInfo(resourceInfo.FullPath);

            if (!repo.IsGitRepo)
            {
                return(HttpNotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(settings));
            }

            io::File.WriteAllText(Path.Combine(resourceInfo.FullPath, "description"), settings.Description);
            if (repo.IsArchived != settings.IsArchived)
            {
                GitUtilities.ToggleArchived(resourceInfo.FullPath);
            }

            return(RedirectToAction("ViewRepo", "Browse", new { repo = repoName }));
        }
Exemplo n.º 2
0
        public IEnumerable <SearchResult> Search(SearchQuery query, FileManager fileManager)
        {
            var repos = from dir in fileManager.DirectoryInfo.EnumerateDirectories()
                        let repoInfo = GitUtilities.GetRepoInfo(dir.FullName)
                                       where repoInfo.IsGitRepo
                                       select repoInfo;

            foreach (var repo in repos)
            {
                if (query.Terms.All(t => repo.Name.IndexOf(t, StringComparison.OrdinalIgnoreCase) != -1 || repo.Description.IndexOf(t, StringComparison.OrdinalIgnoreCase) != -1))
                {
                    yield return(new SearchResult
                    {
                        LinkText = repo.Name,
                        ActionName = "ViewRepo",
                        ControllerName = "Browse",
                        RouteValues = new { repo = repo.Name },
                        Lines = new List <SearchLine>
                        {
                            new SearchLine {
                                Line = repo.Description
                            },
                        },
                    });
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult ViewRepo(string repo)
        {
            var resourceInfo = this.FileManager.GetResourceInfo(repo);

            if (resourceInfo.Type != ResourceType.Directory)
            {
                return(HttpNotFound());
            }

            var repoInfo = GitUtilities.GetRepoInfo(resourceInfo.FullPath);

            if (!repoInfo.IsGitRepo)
            {
                return(HttpNotFound());
            }

            AddRepoBreadCrumb(repo);

            var lastCommit = GitUtilities.GetLogEntries(resourceInfo.FullPath, 1).FirstOrDefault();

            ViewBag.RepoInfo    = GitUtilities.GetRepoInfo(resourceInfo.FullPath);
            ViewBag.LastCommit  = lastCommit;
            ViewBag.CurrentTree = lastCommit != null?GitUtilities.GetTreeInfo(resourceInfo.FullPath, "HEAD") : null;

            ViewBag.Refs = GitUtilities.GetAllRefs(resourceInfo.FullPath);

            return(View());
        }
Exemplo n.º 4
0
        public ActionResult Index(bool archived = false)
        {
            var directory = this.FileManager.DirectoryInfo;

            ViewBag.Archived = archived;
            var repos = (from dir in directory.EnumerateDirectories()
                         select GitUtilities.GetRepoInfo(dir.FullName)).Where(ri => ri.IsArchived == archived).ToList();

            return(View(repos));
        }
Exemplo n.º 5
0
        public IEnumerable <SearchResult> Search(SearchQuery query, FileManager fileManager)
        {
            var repos = from dir in fileManager.DirectoryInfo.EnumerateDirectories()
                        let repoInfo = GitUtilities.GetRepoInfo(dir.FullName)
                                       where repoInfo.IsGitRepo
                                       select repoInfo;

            return(from repo in repos
                   from searchResult in Search(query, repo, includeRepoName: true)
                   select searchResult);
        }
Exemplo n.º 6
0
        public ActionResult SearchRepo(string repo, string q)
        {
            var resourceInfo = this.FileManager.GetResourceInfo(repo);

            if (resourceInfo.Type != ResourceType.Directory)
            {
                return(HttpNotFound());
            }

            var repoInfo = GitUtilities.GetRepoInfo(resourceInfo.FullPath);

            if (!repoInfo.IsGitRepo)
            {
                return(HttpNotFound());
            }

            return(Search(q, repoInfo));
        }
Exemplo n.º 7
0
        public ActionResult ManageRepo(string repoName)
        {
            var resourceInfo = this.FileManager.GetResourceInfo(repoName);

            if (resourceInfo.Type != ResourceType.Directory)
            {
                return(HttpNotFound());
            }

            var repo = GitUtilities.GetRepoInfo(resourceInfo.FullPath);

            if (!repo.IsGitRepo)
            {
                return(HttpNotFound());
            }

            return(View(new RepoSettings
            {
                Description = repo.Description,
                IsArchived = repo.IsArchived,
            }));
        }