private async Task AddBotAsReviewer(PullRequestOpenedNotification notification) { if (!this.IsReviewer(notification.PullRequest.Reviewers)) { // add the bot as a reviewer await this.bitbucketClient.AddReviewer(notification.PullRequest, new BitbucketParticipant() { User = new BitbucketUser() { Name = this.integrations.Bitbucket.Credentials.UserName }, Role = BitbucketRole.Reviewer }); } }
public async Task OnOpenedHandlerAsync(PullRequestOpenedNotification notification) { Guard.AgainstNullArgument <PullRequestOpenedNotification>(nameof(notification), notification); await this.AddBotAsReviewer(notification); if (await this.HasMergeConflicts(notification.PullRequest)) { // update the pr with needs_work await this.bitbucketClient.SetReviewerStatus(notification.PullRequest, new BitbucketParticipant() { User = new BitbucketUser() { Name = this.integrations.Bitbucket.Credentials.UserName, Slug = this.integrations.Bitbucket.Credentials.UserName }, IsApproved = false, Status = BitbucketStatus.NeedsWork }); // comment with, please fix merge conflicts and add steps for fix await this.bitbucketClient.AddComment(notification.PullRequest, new BitbucketComment() { Text = string.Format(Resources.PullRequest_MergeConflictResolution, notification.PullRequest.ToReference.DisplayName, notification.PullRequest.FromReference.DisplayName) }); //return; } // check other criteria FishEyeChangesets Changesets = await this.FindReviewsByCommits(notification.PullRequest); // check all commits are associated with a review await this.AreAllCommitsReviewed(notification.PullRequest, Changesets); // check for closed review // check for 2 reviewers in complete status await this.ValidateReviewConditions(notification.PullRequest, Changesets); }
public async Task <IActionResult> PullRequestOpened(string @event, string requestId, PullRequestOpenedNotification data) { if (!ModelState.IsValid) { return(this.BadRequest(ModelState)); } await this.pullRequestService.OnOpenedHandlerAsync(data); return(this.Ok()); }