创建对拉请求的评论 [英] Create comment on pull request

查看:159
本文介绍了创建对拉请求的评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GitHub的评论API 似乎允许您在拉取请求上创建评论,但只有当您提供差异中的特定行号才能发表评论时。有没有办法在整个pull request上创建一个注释,相当于在GitHub的web界面的pull request屏幕的底部输入?

GitHub's comment API seems to allow you to create comments on a pull request, but only if you supply a specific line number in the diff to comment on. Is there a way to create a comment on the pull request as a whole, the equivalent of typing at the bottom of the pull request screen in GitHub's web interface?

推荐答案

是的,这是可能的。您所引用的API文档部分涉及到行注释(请求中的提交的特定行上的注释),并且文档说:

Yes, it is possible. The section of the API docs you are referencing relates to line comments (comments on specific lines of the commits in the pull req), and the docs say:


合并请求评论评论是关于统一差异的一部分的评论。它们与Commit Comments(直接应用于提交请求,Pull Request视图之外)和Issue Comments(不引用统一差异的一部分)分开。

Pull Request Review Comments are comments on a portion of the unified diff. These are separate from Commit Comments (which are applied directly to a commit, outside of the Pull Request view), and Issue Comments (which do not reference a portion of the unified diff).

您需要的是那些问题评论,这些评论在本页面

What you need are those Issue comments, which are explained at the top of this page:


Pull Request API允许您列出,查看,编辑,创建甚至合并拉请求。可以通过问题评论API来管理对请求的评论。

The Pull Request API allows you to list, view, edit, create, and even merge pull requests. Comments on pull requests can be managed via the Issue Comments API.

因此,要创建合并请求评论,您实际上需要创建问题评论(因为拉取请求会产生问题来管理它)。 问题评论确认了这一点:

So, in order to create a Pull Request comment, you actually need to create an Issue comment (since a pull request creates an issue to manage it). The page for Issue comments confirms this:


Issue Comments API支持列出,查看,编辑和创建关于问题和请求的注释。

The Issue Comments API supports listing, viewing, editing, and creating comments on issues and pull requests.

因此,要求您需要制作是:

POST /repos/:owner/:repo/issues/:number/comments

你怎么知道哪个问题的评论URL要POST?那么,如果您查看获取单个请求的响应,您会看到它包含一个名为 _links 的属性,并且此属性具有嵌套的注释属性。这是您用来读取和创建请求请求注释的URL,与上面POST请求中使用的注释相同。

How do you know which issue comment URL to POST to? Well, if you look at the response for getting a single pull request, you will see that it contains an attribute called _links, and that this attribute has a nested comments attribute. This is the URL which you should use for reading and creating pull request comments, the same one as to be used in the POST request above.

这篇关于创建对拉请求的评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆