private CheckBox CreateCheckbox(int x, int y, RepositoryVO repository) { CheckBoxRepository checkbox = new CheckBoxRepository(this, x, y++, repository.Name, repository.Selected); checkbox.Toggled += Checkbox_Repository_Toggled; return(checkbox); }
public static void Add(RepositoryVO repository) { if (repository.HasChangesNotStaged) { ProcessService.Execute("git", "add .", repository.Path); } }
public static void Commit(RepositoryVO repository, string message) { if (repository.HasChangesNotCommited) { ProcessService.Execute("git", string.Format(@"commit -m ""{0}""", message), repository.Path); } }
public static void UpdateStatus(RepositoryVO repository) { string response = ProcessService.Execute("git", "status", repository.Path); Match match = Regex.Match(response, ER_BRANCH); repository.Branch = match.Groups["name"].Value; repository.HasChangesNotStaged = Regex.IsMatch(response, ER_HASCHANGES_NOT_STAGED); if (!repository.HasChangesNotStaged) { repository.HasChangesNotStaged = Regex.IsMatch(response, ER_HASCHANGES_UNTRACKED_FILES); } repository.Head = null; match = Regex.Match(response, ER_BRANCH_AHREAD); if ((match != null) && (!string.IsNullOrEmpty(match.Groups["head"].Value))) { repository.Head = Int32.Parse(match.Groups["head"].Value); } match = Regex.Match(response, ER_BRANCH_BEHIND); if ((match != null) && (!string.IsNullOrEmpty(match.Groups["head"].Value))) { repository.Head = 0 - Int32.Parse(match.Groups["head"].Value); } repository.HasChangesNotCommited = Regex.IsMatch(response, ER_HASCHANGES_NOT_COMMITED); repository.HasUnmergedPaths = Regex.IsMatch(response, ER_HASCHANGES_UNMERGED_PATH); }
private string GetBranchInfo(RepositoryVO repository) { StringBuilder builder = new StringBuilder("Branch ( "); builder.Append(repository.Branch); builder.Append(" )"); return(builder.ToString()); }
public static void Push(RepositoryVO repository) { if ((!repository.Head.HasValue) || (repository.Head.Value < 0)) { return; } ProcessService.Execute("git", "push", repository.Path); }
public static void AddPullRequestReviewer(RepositoryVO repository, PullRequestVO pullRequest, string reviewerEmail) { if (!IsConfigurated()) { return; } List <string> reviewers = new List <string>(); string command = _vstsPath; string arguments = string.Format("code pr reviewers add --id {0} --reviewers {1}", pullRequest.ID, reviewerEmail); string response = ProcessService.Execute(command, arguments, repository.Path); }
public static SolutionVO Load(string pathOrName) { string path = GetPath(pathOrName); if (path == null) { return(null); } SolutionVO solution = new SolutionVO(); solution.Name = Path.GetFileNameWithoutExtension(path); solution.Path = path; string solutionText = File.ReadAllText(path); foreach (Match match in Regex.Matches(solutionText, ER_SOLUTION_PROJECT)) { //Project ProjectVO project = new ProjectVO(); project.Name = match.Groups["name"].Value; project.Path = match.Groups["path"].Value; solution.Projects.Add(project); //Repository FileInfo fileSolution = new FileInfo(solution.Path); FileInfo fileInfo = new FileInfo(Path.Combine(fileSolution.Directory.FullName, project.Path)); DirectoryInfo directoryRepository = fileInfo.Directory; if (!Directory.Exists(directoryRepository.FullName)) { Console.WriteLine($"Cant find project Path: {directoryRepository.FullName}"); return(null); } while ((directoryRepository != null) && (!GitService.IsGitFolder(directoryRepository.FullName))) { directoryRepository = directoryRepository.Parent; } if (directoryRepository == null) { continue; } RepositoryVO repository = solution.GetRepositoryByPath(directoryRepository.FullName); if (repository == null) { repository = new RepositoryVO(); repository.Name = directoryRepository.Name; repository.Path = directoryRepository.FullName; solution.Repositories.Add(repository); } project.Repository = repository; repository.Projects.Add(project); } GitService.UpdateStatus(solution); return(solution); }
public static void CheckoutBranch(RepositoryVO repository, string branch) { if (repository.Branch == branch) { return; } List <string> branchs = ListBranchs(repository); if (branchs.Contains(branch)) { ProcessService.Execute("git", string.Format(@"checkout {0}", branch), repository.Path); } }
public void ShowFilesNotCommited(string repositoryName) { RepositoryVO repository = this.Solution.GetRepositoryByName(repositoryName); Dictionary <string, string> files = GitService.ListFilesNotCommited(repository); bool updated = WindowManager.ShowDialogFilesNotStaged("Files Not Commited", files); if (!updated) { return; } GitService.UpdateStatus(this.Solution); this.RefreshUI(); }
public static bool HasCommits(RepositoryVO repository, WorkItemVO workItem, string branchBase) { string response = ProcessService.Execute("git", string.Format("cherry {0} {1}", branchBase, workItem.TaskID), repository.Path); string[] lines = response.Split("\r\n"); foreach (string line in lines) { if (!string.IsNullOrEmpty(line.Trim())) { return(true); } } return(false); }
private static Dictionary <string, List <string> > ListFiles(RepositoryVO repository) { Dictionary <string, List <string> > files = new Dictionary <string, List <string> >(); string response = ProcessService.Execute("git", "status", repository.Path); string[] lines = response.Split("\n"); string lastSector = null; List <string> buffer = new List <string>(); for (int i = 0; i < lines.Length; i++) { string line = lines[i]; line = line.Trim(); if (string.IsNullOrEmpty(line)) { continue; } if (line.Contains("(") && line.Contains(")")) { continue; } string sector = GetLineSector(line); if (sector != null) { if ((lastSector != null) && (buffer.Count > 0)) { files.Add(lastSector, buffer); } buffer = new List <string>(); lastSector = sector; continue; } if (lastSector != null) { buffer.Add(line); } } if ((lastSector != null) && (buffer.Count > 0)) { if (files.ContainsKey(lastSector)) { files[lastSector].AddRange(buffer); } else { files.Add(lastSector, buffer); } } return(files); }
public static void CreateBranch(RepositoryVO repository, WorkItemVO workItem) { string branch = workItem.TaskID; if (repository.Branch == branch) { return; } List <string> branchs = ListBranchs(repository); if (branchs.Contains(branch)) { CheckoutBranch(repository, branch); return; } ProcessService.Execute("git", string.Format(@"checkout -b {0}", branch), repository.Path); ProcessService.Execute("git", string.Format(@"push --set-upstream origin {0}", branch), repository.Path); }
public static List <string> ListPullRequestReviewers(RepositoryVO repository, PullRequestVO pullRequest) { if (!IsConfigurated()) { return(null); } List <string> reviewers = new List <string>(); string command = _vstsPath; string arguments = @"code pr reviewers list --id " + pullRequest.ID; string response = ProcessService.Execute(command, arguments, repository.Path); TableVO table = new TableVO(response); foreach (TableRowVO row in table.Rows) { reviewers.Add(row.GetValue("Email")); } return(reviewers); }
public void ShowBranchs(string repositoryName) { RepositoryVO repository = this.Solution.GetRepositoryByName(repositoryName); List <string> branchs = GitService.ListBranchs(repository); string branch = WindowManager.ShowDialogList("Branchs", branchs); if (string.IsNullOrEmpty(branch)) { return; } GitService.UpdateStatus(this.Solution, true); if (!EnsureHasNoChanges()) { return; } GitService.CheckoutBranch(this.Solution, branch); GitService.UpdateStatus(this.Solution, true); this.RefreshUI(); }
private static Dictionary <string, string> ListFiles(RepositoryVO repository, string type) { Dictionary <string, string> files = new Dictionary <string, string>(); Dictionary <string, List <string> > filesTypes = ListFiles(repository); if (!filesTypes.ContainsKey(type)) { return(files); } List <string> filesType = filesTypes[type]; for (int i = 0; i < filesType.Count; i++) { string fileType = filesType[i]; string[] parts = fileType.Split(":"); files.Add(fileType, parts.Length > 1 ? parts[1].Trim() : fileType); } return(files); }
private void InsertRepositoryInfo(List <View> views, RepositoryVO repository, int x, int y) { if (repository.HasUnmergedPaths) { views.Add(CreateLabel(x, y, " ", COLOR_UNMERGED_PATH)); } x = x + 2; if (repository.HasChangesNotStaged) { views.Add(CreateLabel(x, y, " ", COLOR_NOT_STAGED)); } x = x + 2; if (repository.HasChangesNotCommited) { views.Add(CreateLabel(x, y, " ", COLOR_NOT_COMMITTED)); } x = x + 2; if (repository.Head.HasValue) { views.Add(CreateLabel(x, y, repository.Head.Value.ToString("+0;-#"))); } }
public static List <string> ListBranchs(RepositoryVO repository) { List <string> branchs = new List <string>(); string response = ProcessService.Execute("git", "branch -a", repository.Path); string[] lines = response.Split("\n"); for (int i = 0; i < lines.Length; i++) { string line = lines[i]; if (line.StartsWith("*")) { line = line.Substring(1); } line = line.Trim(); if (line.StartsWith("remotes/origin/")) { line = line.Substring("remotes/origin/".Length); } if (line.EndsWith("\r")) { line = line.Substring(0, line.Length - ("\r".Length)); } if (line.Contains("->")) { continue; } if (string.IsNullOrEmpty(line)) { continue; } if (branchs.Contains(line)) { continue; } branchs.Add(line); } return(branchs); }
public void OpenCodeRepository(string repositoryName) { RepositoryVO repository = this.Solution.GetRepositoryByName(repositoryName); ProcessService.OpenCode(repository.Path); }
public static void CreatePullRequest(RepositoryVO repository, WorkItemVO workItem) { string command = _vstsPath; string arguments = string.Format(@"code pr create --title ""{0} {1}"" --work-items {2}", workItem.TaskID, workItem.Name, workItem.Code); string response = ProcessService.Execute(command, arguments, repository.Path); }
public static void Pull(RepositoryVO repository) { ProcessService.Execute("git", "pull", repository.Path); }
public static Dictionary <string, string> ListFilesNotStaged(RepositoryVO repository) { return(ListFiles(repository, ER_HASCHANGES_NOT_STAGED)); }
private string GetProjectsName(RepositoryVO repository) { return(string.Format("Projects {0}", GetProjectNames(repository.Projects))); }
public static void MergeBranch(RepositoryVO repository, string branchBase) { ProcessService.Execute("git", string.Format(@"merge {0}", branchBase), repository.Path); }
public static void Fetch(RepositoryVO repository) { ProcessService.Execute("git", "fetch", repository.Path); }
public static Dictionary <string, string> ListFilesNotCommited(RepositoryVO repository) { return(ListFiles(repository, ER_HASCHANGES_NOT_COMMITED)); }