api - 从 bitbucket api 2.0 获取最新的标签提交
问题描述
我正在尝试创建一个实用工具,我需要将最新标签提交给特定的存储库。到目前为止我已经尝试过:
curl -X GET \
https://api.bitbucket.org/2.0/repositories/<team>/<reposlug>/refs/tags \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Basic encodedpasswd' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: api.bitbucket.org'
我得到的回报是分页响应,如下所示:
{
"pagelen": 10,
"values": [
{
"name": "release-1.2",
"links": {
},
"tagger": {
},
"date": "2019-11-15T11:53:56+00:00",
"message": "[maven-release-plugin]copy for tag release-1.2\n",
"type": "tag",
"target": {
}
},
{
"name": "release-1.3",
"links": {
},
"tagger": {
},
"date": "2019-11-20T07:53:51+00:00",
"message": "[maven-release-plugin]copy for tag release-1.3\n",
"type": "tag",
"target": {
}
}
],
"page": 1
}
现在根据我在这里引用的文档,tags
在返回时是特别订购的,但我对为什么该值release-1.3
不是响应中的第一个感到困惑。我想我错过了一些东西。或者,如果这是预期的顺序,我怎样才能实现标签按date
属性排序,以获取最新的标签。
解决方案
所以我能够通过使用sort
on attribute来解决这个问题target.date
。
curl -X GET \
https://api.bitbucket.org/2.0/repositories/<team>/<reposlug>/refs/tags?sort=target.date \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Basic encodedpasswd' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: api.bitbucket.org'
推荐阅读
- ruby-on-rails - PostgreSQL 和 Rails 有关联吗?即使我执行了命令“$ psql --version”,我也无法验证是否安装了 PostgreSQL
- python - 加载目录后在 pyqt 中启用选项卡
- javascript - 如何实现角色的值
- vue.js - Vue.js - 防止父元素中的 dblclick 事件
- android - Android 应用在 Pixel 4a 上留下黑色底栏
- php - PHP检查字符串是否为UTF-8的最快方法?
- c# - 多个预制件在 X 和 Y 轴上随机生成
- json - SwiftUI 如何从响应 JSON API 中分离单个数据
- powerbi - 电源查询(powerbi)数据结构:创建横截面-时间数据结构(面板数据)
- python - 在 Python 中绘制 3D 矢量场