public ActionResult Commits(Guid id, string encodedName, int?page = null) { 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.Value, 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) })); } }
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); }
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(); }
public ActionResult Commits(string id, string encodedName) { ViewBag.ID = id; 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(); }
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()); }
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; return(View(new RepositoryCommitsModel { Commits = commits, Name = repo.Name })); } }
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(); }
public void CarregarCommits() { try { List <RepositorioModel> MeusRepo = RecuperarRepositorios(); List <RepositorioModel> LogRepositorios = RetornarArquivoDeLog(); foreach (RepositorioModel repositorio in MeusRepo) { RepoErro = ConfigurationManager.AppSettings.Get("DefaultRepositoriesDirectory") + repositorio.RepoName; using (var browser = new RepositoryBrowser(Path.Combine(ConfigurationManager.AppSettings.Get("DefaultRepositoriesDirectory"), repositorio.RepoName))) { IEnumerable <string> branchs = browser.GetBranches(); foreach (var NomeBranchs in branchs) { string referenceName = NomeBranchs; int totalCount; repositorio.Branchs.Add(new BranchModel { BranchName = NomeBranchs, Commits = new List <CommitModel>(), repositoryName = repositorio.RepoName }); IEnumerable <RepositoryCommitModel> commits = browser.GetCommits(NomeBranchs, 1, 99, out referenceName, out totalCount); foreach (var commit in commits) { itemModificado = 0; contadorMudancas += 1; var model = browser.GetCommitDetail(commit.ID); List <RepositoryCommitChangeModel> mudancas = new List <RepositoryCommitChangeModel>(); if (model.Changes.Count() > 0 && model.Changes != null) { mudancas = model.Changes.ToList(); } Console.WriteLine("Commit: " + contadorMudancas); repositorio.Branchs.First(x => x.BranchName == NomeBranchs).Commits.Add(new CommitModel { Author = commit.Author, AuthorEmail = commit.AuthorEmail, Date = commit.Date, Name = commit.Name, Message = commit.Message, BranchName = NomeBranchs, Id = commit.ID, ItemsModificados = new List <ItemsCommitModel>(), RepoName = repositorio.RepoName }); for (int i = 0; i < mudancas.Count(); i++) { repositorio.Branchs.First(x => x.BranchName == NomeBranchs).Commits.First(y => y.Id == commit.ID).ItemsModificados.Add(new ItemsCommitModel { ChangeId = mudancas[i].ChangeId, Name = mudancas[i].Name, Path = mudancas[i].Path, Status = mudancas[i].Status.ToString() }); Console.WriteLine("Item modificado: " + i); //Console.Clear(); itemModificado += 1; } Console.Clear(); break; } } } } if (LogRepositorios != null) { if (LogRepositorios.Count > 0) { VerificarMudancasNoRepositorio(MeusRepo, LogRepositorios); } } SalvarLogUltimosCommits(MeusRepo); } catch (Exception ex) { using (StreamWriter file = new StreamWriter(ConfigurationManager.AppSettings.Get("DefaultLogDirectory").ToString() + "ERRO_" + DateTime.Today.ToString("dd-MM-yyyy") + ".log", true, System.Text.Encoding.Default)) { file.WriteLine("Exception: " + ex); file.WriteLine("_-_-_"); file.WriteLine("Caminho do repositorio: " + RepoErro); file.WriteLine("Mudança de numero: " + contadorMudancas.ToString()); file.WriteLine("Item modificado de numero: " + itemModificado.ToString()); file.Flush(); file.Close(); file.Dispose(); } throw; } }
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) }); } }