Exemple #1
0
        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();
        }