如何访问完整的源代码的老犯到位桶?(How to access full source of old

2019-07-18 17:40发布

讨厌要问这对流量,但对我的生活,我不能找出或发现关于如何访问一个旧的源中的新位桶格式提交的文档。 这甚至可能了吗? 很沮丧!

Answer 1:

我知道你要下载经过到位桶Web界面的旧版本不使用水银/ Git的客户端。

检查此相关的问题 。 上的评论,有人说,有没有办法做到这一点。 幸运的是,这并不完全正确。

通过导航上到位桶项目页面,我发现没有链接下载任意版本。 有链接,下载特定的标签,格式如下:

https://bitbucket.org/owner/repository/get/v0.1.2.tar.gz

但是,通过调整了一下上面的网址,通过提交哈希改变变量名,如:

https://bitbucket.org/owner/repository/get/A0B1C2D.tar.gz

实际上,你可以下载一个特定版本。

如前所述通过Rakka愤怒的评论,更换.tar.gz.zip也可以。



Answer 2:

我试图找出是否有可能浏览较早的代码提交像您可以在GitHub上,它把我带到这里。 我用我发现这里的信息,并摆弄周围与网址后,我居然找到了一种方法来浏览代码的老款为好。

当你浏览你的代码的URL是这样的:

https://bitbucket.org/user/repo/src/

并通过添加在这样的端提交散列:

https://bitbucket.org/user/repo/src/a0328cb

您可以在该犯点浏览的代码。 我不明白为什么有选购直接提交没有下拉框,该功能已经存在。 奇怪。



Answer 3:

步骤1


第2步


第3步


第4步


最后一步



Answer 4:

万一有人在我的船,其中没有这些答案的工作完全,这里就是我所做的。

也许我们在内部到位桶服务器设置有点不同于大多数,但这里是我通常去只是为了查看在主分支中的文件的网址:

https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse

如果我选择不是从下拉菜单主不同的分支,我得到这样的:

https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=refs%2Fheads%2F<BRANCH_NAME>

所以,我想这样做的,它的工作:

https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=<COMMIT_ID>

现在我可以浏览整个回购,因为它是在犯下的时间。



Answer 5:

伟大的答案来自前几年。 现在已经到位桶使它更加容易。

标签要下载(如鲁迪Matela在答复中提到)的提交。

然后头向下载,然后点击“标签”选项卡,你会得到下载多个选项。



Answer 6:

根据记录,你也可以围绕网址,这样的玩具:

当浏览最新的源代码,你碰到这样的: https://bitbucket.org/my/repo/src/latestcommithash/my.file?at=master

简单地改变承诺哈希并删除GET参数: https://bitbucket.org/my/repo/src/wantedcommithash/my.file

得+1 @Hein A.Grønnestad以上:它的所有工作,真的不知道为什么没有什么在GUI中使用它。



Answer 7:

可以查看文件向上的源到特定的通过附加提交?until=<sha-of-commit>在URL(文件名之后)。



Answer 8:

我知道这是为时已晚,但API 2.0,你可以做

从命令符合:

curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>

或PHP中:

$data = json_decode(file_get_contents("https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>", true));

那么你有你的文件的历史记录(从最近提交到最旧的):

{
"pagelen": 50,
"values": [
    {
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<hash>/<path_file>"
        },
        "meta": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD>/<path_file>?format=meta"
        },
        "history": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD>/<path_file>"
        }
      },
      "commit": {
        "hash": "<HEAD>",
        "type": "commit",
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD>"
          },
          "html": {
            "href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD>"
          }
        }
      },
      "attributes": [],
      "path": "<path_file>",
      "type": "commit_file",
      "size": 31
    },
    {
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>"
        },
        "meta": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>?format=meta"
        },
        "history": {
          "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD~1>/<path_file>"
        }
      },
      "commit": {
        "hash": "<HEAD~1>",
        "type": "commit",
        "links": {
          "self": {
            "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD~1>"
          },
          "html": {
            "href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD~1>"
          }
        }
      },
      "attributes": [],
      "path": "<path_file>",
      "type": "commit_file",
      "size": 20
    }
  ],
  "page": 1
}

其中values > links > self提供文件在历史的时刻,你可以找回curl <link>file_get_contents(<link>)

最终,在命令行,你可以过滤:

 curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>?fields=values.links.self

在PHP中,只是做一个foreach对数组循环$data

注意:如果<path_file>/你必须把它转换成%2F

看到这里的文档: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/filehistory/%7Bnode%7D/%7Bpath%7D



文章来源: How to access full source of old commit in BitBucket?
标签: bitbucket