public void CreatePullRequest() { if (this.Solution == null) { return; } if (this.WorkItem == null) { MessageBox.ErrorQuery(50, 7, "VSTS", "You must select a work item first", "Ok"); return; } if (!EnsureHasNoChanges()) { return; } WindowManager.ShowLog(); GitService.CheckoutBranch(this.Solution, this.WorkItem.TaskID); GitService.Pull(this.Solution); GitService.Push(this.Solution); GitService.UpdateStatus(this.Solution, true); if (!EnsureHasNoChanges()) { WindowManager.CloseLog(); return; } GitService.Push(this.Solution); foreach (RepositoryVO repository in this.Solution.Repositories) { if ((!repository.Selected)) { continue; } if (!GitService.HasCommits(repository, this.WorkItem, this.BranchBase)) { continue; } bool isPullRequestAlreadyCreated = false; List <PullRequestVO> pullRequests = AzureDevOpsService.ListPullRequests(repository.Path); foreach (PullRequestVO pullRequest in pullRequests) { if (isPullRequestAlreadyCreated = ((pullRequest.Repository == repository.Name) && (pullRequest.Title.StartsWith(this.WorkItem.TaskID)))) { break; } } if (isPullRequestAlreadyCreated) { continue; } //Create PR AzureDevOpsService.CreatePullRequest(repository, this.WorkItem); } GitService.UpdateStatus(this.Solution, true); WindowManager.CloseLog(); this.RefreshUI(); }
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(); }