如何在 github pull 请求中选择/注释一系列行?

在 github 上有一个选项可以对文件中的一系列行进行注释,请参阅 如何在 github 中引用特定的行或行的范围?

但是,是否有类似的选项,以评论范围内的行拉请求? enter image description here

当我点击一行时,只有一行被高亮显示为黄色,R # # # (例如 R446)被添加到 url 中,点击另一行并按下 shift 键没有任何作用。我试图改变网址 R446-450,但它没有做任何事情。改成450-458英镑也没什么用。而且,即使是单一的高亮线似乎也不会影响任何东西。

单击悬停时出现的“蓝色加号”将创建注释窗口,但它只对一行进行注释。

注释单行导致 enter image description here

在 pull-request 页面上注释只显示选定/注释行上面的4行,但我感兴趣的是显示7行,而不是4行

40538 次浏览

It isn't possible to comment on multiple lines in a pull request review at GitHub. I hope they will create a new feature where this is possible.

But what you can do, there is a little (time consuming) workaround:

If you go in to the code, in the branch with the changes, you can select multiple lines and then copy a permalink for those lines. When you paste this link into your review comment, it will be shown as a code snippet.

For more, read this: https://help.github.com/articles/creating-a-permanent-link-to-a-code-snippet/

Update Github has released a new feature where this is possible. See VonC's answer :-)

The multiline comment feature is now available on GitHub. Enjoy!

Since Oct. 2019, Nat Friedman (CEO of GitHub) declares that feature available
(And, see below, since Feb. 2020, multi-lines comment reference is possible)

🔥
Multi-line comments are here!
Click and drag to comment on multiple lines in a pull request diff. ✨

These little quality-of-life improvements are at the heart of what we love doing at GitHub. 🥰

Multi-line PR comment selection

Thanks to:


Nick Craver immediately asks:

Follow-up question: are there plans to support suggestions?
It seems to apply to the last line at the moment:

multi-line suggestion?

That would be, according to Nat, "Coming early next year".

Update Feb. 2020: "A new interaction for multi-line pull request comments "

To leave a comment referencing multiple lines, you can either:

  • click on a line number in the diff view, hold Shift, click on a second line number and click the "+" button next to the second line number; or
  • click and hold to the right of a line number, drag and then release the mouse when you’ve reached the desired line.

This was announced by Nat Friedman

Shipping today on GitHub: multi-line suggestions!

multi-lines example

With, again, special thanks to Melanie Gilman, Pat Nakajima, Mike Chlipala, Joel Califa, John Caine, Matt Colyer and , and Kelly Arwine.

GitHub Changelog also references this.


Henry adds an observation

A smaller side effect, but I assume being able to share a multi-line diff in the PR is new too!

Example: babel/babel PR 10511 diff-L261-L263

Share multi line

But that was available since July 2019

Multi-line comments have arrived! Git has introduced new feature today for multiline comment please have look

By click on + icon and then drag to multiple lines

https://twitter.com/github/status/1179101186437324801

To reference multiple lines click on a line number in the diff view, hold shift, and click on a second line number. The URL of the page will update and can be shared with fellow contributors.

To leave a comment referencing multiple lines click and hold to the right of a line number, drag, and then release the mouse when you’ve reached the desired line.