Beispiel #1
0
        public ActionResult Log(
            string branch, string path, int skip = 0, int take = 50)
        {
            var repository = new GitVersioningSystem(path, branch);

            var model = new CommitHistoryViewModel {
                Branch         = branch,
                RepositoryPath = repository.RootPath,
                Commits        = repository.GetCommitMessages(skip, take)
            };

            return(View(model));
        }
Beispiel #2
0
        public async Task <IActionResult> CommitHistory(string userName, string repoName, string branch, string path)
        {
            var repo =
                _context.Repos.Include(r => r.Author).Include(r => r.AllowedUser)
                .FirstOrDefault(
                    r =>
                    String.Equals(r.RepoName.ToLower(), repoName.ToLower()) &&
                    String.Equals(r.Author.UserName.ToLower(), userName.ToLower()));

            if (repo == null)
            {
                return(StatusCode(404));
            }
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (!repo.CheckAccess(user))
            {
                return(StatusCode(403));
            }
            var fullRepoName = $"{userName.ToLower()}-{repoName.ToLower()}";
            var branches     = _gitService.UpdateLocalRepo(_environment, fullRepoName, branch);
            List <GitCommit> hisrory;

            try
            {
                hisrory = _gitService.GetRepoCommitHistory(_environment, fullRepoName);
            }
            catch (Exception ex)
            {
                return(RedirectToRoute("Error", new { id = 703 }));
            }
            var model = new CommitHistoryViewModel
            {
                Commits            = hisrory,
                RepoRootPath       = $"/{userName}/{repoName}",
                Path               = new List <string>(new[] { userName, repoName }),
                Branches           = branches,
                CurrentBranchIndex = branches.IndexOf(branch)
            };

            return(View(model));
        }
Beispiel #3
0
 public MainWindowViewModel(IEnumerable <CommitLineViewModel> commits)
 {
     CommitHistory = new CommitHistoryViewModel(commits);
 }