问题描述
似乎允许您在拉取请求上创建评论,但只有当您提供差异中的特定行号才能发表评论时。有没有办法在整个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:
您需要的是那些问题评论,这些评论在:
What you need are those Issue comments, which are explained at the top of this page:
因此,要创建合并请求评论,您实际上需要创建问题评论(因为拉取请求会产生问题来管理它)。 确认了这一点:
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:
因此,,您会看到它包含一个名为 _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.
这篇关于创建对拉请求的评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!