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 void AddReviewerToPullRequest() { if (this.Solution == null) { return; } if (this.WorkItem == null) { MessageBox.ErrorQuery(50, 7, "VSTS", "You must select a work item first", "Ok"); return; } string reviewerEmail = "*****@*****.**"; reviewerEmail = WindowManager.ShowDialogText("Choose the Reviewer", "E-mail:", reviewerEmail); if (string.IsNullOrEmpty(reviewerEmail)) { return; } WindowManager.ShowLog(); foreach (RepositoryVO repository in this.Solution.Repositories) { if ((!repository.Selected)) { continue; } List <PullRequestVO> pullRequests = AzureDevOpsService.ListPullRequests(repository.Path); PullRequestVO pullRequestWorkItem = null; foreach (PullRequestVO pullRequest in pullRequests) { if (((pullRequest.Repository != repository.Name) || (!pullRequest.Title.StartsWith(this.WorkItem.TaskID)))) { continue; } pullRequestWorkItem = pullRequest; break; } if (pullRequestWorkItem == null) { continue; } List <string> reviewers = AzureDevOpsService.ListPullRequestReviewers(repository, pullRequestWorkItem); if (reviewers.Contains(reviewerEmail)) { continue; } AzureDevOpsService.AddPullRequestReviewer(repository, pullRequestWorkItem, reviewerEmail); } WindowManager.CloseLog(); this.RefreshUI(); }
public static List <PullRequestVO> ListPullRequests(string workingDirectory) { if (!IsConfigurated()) { return(null); } List <PullRequestVO> pullRequests = new List <PullRequestVO>(); string command = _vstsPath; string arguments = @"code pr list"; string response = ProcessService.Execute(command, arguments, workingDirectory); TableVO table = new TableVO(response); foreach (TableRowVO row in table.Rows) { PullRequestVO pullRequest = new PullRequestVO(); pullRequest.ID = Int32.Parse(row.GetValue("ID")); pullRequest.Title = row.GetValue("Title"); pullRequest.Repository = row.GetValue("Repository"); pullRequests.Add(pullRequest); } return(pullRequests); }
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); }