Link 到 stash / bitbucket 中的特定代码行?

Link to specific line(s) of code in stash / bitbucket?

通过 github 我们可以使用形式为

的 URL
www.github.com/username/repo/filename.c#L20-L45

请注意末尾的 #L20-L45,当页面在浏览器中加载时,它会突出显示第 20 到第 45 行代码。

这个约定在 stash / bitbucket 中似乎没有以相同的方式工作 - 是否有可能以某种方式 link 某些代码行?

在 BitBucket 中,URL 应该以 #lines-x:y

结尾

示例:

https://bitbucket.org/stangenberg/docker-docker/src/1ac537b84855db2cc5ee0caf31c782900e094d8e/docker.sh#lines-13:15

关于 Stash(现在 2019+ renamed BitBucket Server), Stash 3.8 in 2015 is supposed to support deep linking with multiline selection. Issue BSERV-2477

With just shift+click, a developer can select a range of lines, then add separate lines to the selection with command+click (or control+click), then copy the URL and share their selection with other developers.

The OP confirms :

The stash url generated has #13-15 at the end, i.e. it is of the form:

https://bitbucket.org/stangenberg/docker-docker/src/1ac537b84855db2cc5ee0caf31c782900e094d8e/docker.sh#13-15

作为cellepo notes :

  • 这不能在拉 request/code-review 页面中完成 (https://bitbucket.../pull-requests/...),
    但是
  • 它可以在源页面 (https://bitbucket.../src/...) 上完成,如上述示例 URL。

在我看来,url 行结尾可能有不同的语法,可能根据不同的 Bitbucket 版本...

@VonC 回答很好 - 我认为它以前对我有用,但显然它不再适合我了,我猜不同的 BitBucket 版本可能会有所不同..

无论差异的原因是什么,如果@VonC Answer 不适合你,试试这个(强调 #7-8):

bitbucket.your.domain/.../your/project/structure/.../yourfile.filetype#7-8

UI 的渲染与@VonC 链接示例有点不同 - 只是行号间距的蓝色突出显示(而不是代码的黄色突出显示):

该渲染看起来与@VonC 的 [非连续] 多行选择相同 - 在我的 Bitbucket 版本中,使用 CMD + click 的非连续选择同样有效(如下 - 重点在 ,10,12)

bitbucket.your.domain/.../your/project/structure/.../yourfile.filetype#7-8,10,12

为了突出显示 BitBucket 中的多个块,URL 应该以 #lines-a:b,c:d, ...

结尾

警告:删除 %20 如果 URL

中出现空格