Ejemplo n.º 1
0
        /// <inheritdoc/>
        public async Task <PullRequestDetailModel> PostPendingReviewCommentReply(
            ILocalRepositoryModel localRepository,
            string pendingReviewId,
            string body,
            string inReplyTo)
        {
            var address = HostAddress.Create(localRepository.CloneUrl.Host);
            var graphql = await graphqlFactory.CreateConnection(address);

            var comment = new AddPullRequestReviewCommentInput
            {
                Body                = body,
                InReplyTo           = new ID(inReplyTo),
                PullRequestReviewId = new ID(pendingReviewId),
            };

            var addComment = new Mutation()
                             .AddPullRequestReviewComment(comment)
                             .Select(x => new
            {
                x.Comment.Repository.Owner.Login,
                x.Comment.PullRequest.Number
            });

            var result = await graphql.Run(addComment);

            await usageTracker.IncrementCounter(x => x.NumberOfPRReviewDiffViewInlineCommentPost);

            return(await ReadPullRequestDetail(address, result.Login, localRepository.Name, result.Number));
        }
        /// <inheritdoc/>
        public async Task <IPullRequestReviewCommentModel> PostPendingReviewComment(
            ILocalRepositoryModel localRepository,
            IAccount user,
            string pendingReviewId,
            string body,
            string commitId,
            string path,
            int position)
        {
            var address = HostAddress.Create(localRepository.CloneUrl.Host);
            var graphql = await graphqlFactory.CreateConnection(address);

            var comment = new AddPullRequestReviewCommentInput
            {
                Body                = body,
                CommitOID           = commitId,
                Path                = path,
                Position            = position,
                PullRequestReviewId = pendingReviewId,
            };

            var addComment = new Mutation()
                             .AddPullRequestReviewComment(comment)
                             .Select(x => new PullRequestReviewCommentModel
            {
                Id                  = x.Comment.DatabaseId.Value,
                NodeId              = x.Comment.Id,
                Body                = x.Comment.Body,
                CommitId            = x.Comment.Commit.Oid,
                Path                = x.Comment.Path,
                Position            = x.Comment.Position,
                CreatedAt           = x.Comment.CreatedAt.Value,
                DiffHunk            = x.Comment.DiffHunk,
                OriginalPosition    = x.Comment.OriginalPosition,
                OriginalCommitId    = x.Comment.OriginalCommit.Oid,
                PullRequestReviewId = x.Comment.PullRequestReview.DatabaseId.Value,
                User                = user,
                IsPending           = true,
            });

            var result = await graphql.Run(addComment);

            await usageTracker.IncrementCounter(x => x.NumberOfPRReviewDiffViewInlineCommentPost);

            return(result);
        }