github - 链接到 stash/bitbucket 中的特定代码行?

标签 github bitbucket bitbucket-server

通过 github,我们可以使用表单的 URL

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

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

这个约定在 stash/bitbucket 中的工作方式似乎不同 - 是否可以以某种方式链接到某些代码行?

最佳答案

在 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 应该支持多行选择的深度链接。 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.


https://info.seibert-media.net/download/attachments/11113140/Stash-38.png?version=1&modificationDate=1474904524000&api=v2
The OP 确认 in the comments :

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 指出的 in the comments :
  • 这不能在拉取请求/代码审查页面( https://bitbucket.../pull-requests/... )中完成,
    但是
  • 它可以在源页面( https://bitbucket.../src/... )上完成,就像前面提到的示例 URL 一样。
  • 关于github - 链接到 stash/bitbucket 中的特定代码行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59743484/

    相关文章:

    git pull from remote ...我可以 pull 一个特定的提交吗?

    c# - 在 Visual Studio 中复制文件而不使用 git 历史记录

    git - 是否可以使用 Bitbucket 在 TFS 上进行持续集成?

    git - Atlassian Stash 表示第二个 pull 请求已远程 merge

    github - 为每个 Travis 拉取请求构建运行 Coverity 扫描

    git rebase 在长期(远程)功能分支上

    .net - 保护 git 存储库中的文件

    git - 如何将多个远程设备的git-lfs流量定向到单个端点?

    git - 如何在不提交/添加任何文件或修改任何文件的情况下检查远程 GIT 存储库权限

    git - 是什么导致 git push 突然失败 "User was holding a relation lock for too long"?