我找不到关于如何以新的位桶格式访问旧提交的源代码的文档。这还有可能吗?
当前回答
我知道这已经太迟了,但是有了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
}
其中> 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中,只需在数组$data上做一个foreach循环。
注意:如果<path_file>有一个/,你必须在%2F中转换它。
在这里查看医生:https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/filehistory/%7Bnode%7D/%7Bpath%7D
其他回答
在我的情况下,Atlassian Bitbucket v6.10
https://<bitbucket.myserver.it>/projects/<myproject>/repos/<myrepo>/browse?at=<full-commit-hash>
为了记录,你也可以这样摆弄url:
在浏览最新的源代码时,你会看到如下内容: https://bitbucket.org/my/repo/src/latestcommithash/my.file?at=master
简单地改变提交哈希并删除GET参数: https://bitbucket.org/my/repo/src/wantedcommithash/my.file
@Hein A. Grønnestad上面:它都在工作,真的很好奇为什么GUI中没有任何东西可以使用它。
步骤1
步骤2
步骤3
步骤4
最后一步
几年前的回答很好。现在Bitbucket让它变得更容易了。
标记您想要下载的Commit(如Rudy Matela的回答所述)。
然后转到下载,点击“标签”标签,你会得到多个下载选项。
以防有人和我一样,这些答案都不正确,下面是我做的。
也许我们内部Bitbucket服务器的设置与大多数服务器有点不同,但这是我通常去查看主分支中的文件的URL:
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>
现在我可以浏览整个回购,因为它是在提交时。
推荐文章
- Git克隆/拉不断冻结在“存储密钥在缓存?”
- git推挂在Total line之后
- Bitbucket上的Git:总是要求密码,即使上传了我的公共SSH密钥
- 无法推送到远程分支,无法解析到分支
- 错误“更新被拒绝,因为远程包含您在本地没有的工作”
- 如何在BitBucket中访问旧提交的完整源代码?
- BitBucket -下载ZIP格式的源代码
- 存储库访问被拒绝。通过部署键的访问是只读的
- 如何将所有分支的Git存储库从Bitbucket移动到GitHub?
- 如何在Bitbucket中标记嵌套列表项?
- 登录时启动ssh-agent
- Bitbucket git证书,如果与谷歌注册
- 您的配置指定合并<分支名称>从远程,但没有这样的参考是取得。