예제 #1
0
        private async Task <PullRequest> GetPullRequest(string token, int pullRequestNumber, string repositoryOwner, string repositoryName, long subscriptionId, EventContext eventContext)
        {
            try
            {
                var prInfo = await _gitHubRepositoryPullRequestService.GetPullRequest(token
                                                                                      , pullRequestNumber
                                                                                      , repositoryOwner
                                                                                      , repositoryName);

                return(prInfo.ToPullRequest(subscriptionId));
            }
            catch (Exception e)
            {
                _logger.LogError("PullRequestEventHandler Exception: {GitHubDelivery} {exception} | Cannot fetch the pullRequestInfo.",
                                 eventContext.WebHookEvent.GitHubDelivery, e.ToString());

                //TODO fill it later during the job. Don't fail it here.
                return(new PullRequest()
                {
                    SubscriptionId = subscriptionId,
                    Number = pullRequestNumber,
                    PullRequestAnalyzeStatus = PullRequestAnalyzeStatus.NotAnalyzed
                });
            }
        }
예제 #2
0
        private async Task InitPullRequest(Subscription subscription, PullRequest pullRequest)
        {
            if (pullRequest.PullRequestInfo != null)
            {
                return;
            }

            pullRequest.PullRequestInfo = await _gitHubRepositoryPullRequestService.GetPullRequest(_installationClient.AccessToken.Token
                                                                                                   , (int)pullRequest.Number
                                                                                                   , subscription.Owner
                                                                                                   , subscription.Repo);

            pullRequest.PullRequestAnalyzeStatus = pullRequest.PullRequestInfo.IsMegaPR() ? PullRequestAnalyzeStatus.NotAnalyzedMegaPR : PullRequestAnalyzeStatus.NotAnalyzed;

            _dbContext.Attach(pullRequest);
            _dbContext.Entry(pullRequest).Property(q => q.PullRequestInfo).IsModified          = true;
            _dbContext.Entry(pullRequest).Property(q => q.PullRequestAnalyzeStatus).IsModified = true;

            await _dbContext.SaveChangesAsync();
        }