我正在尝试创建一个实用工具,我需要为此工具将最新标签提交到特定的仓库。 到目前为止,我已经尝试过:
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
}
现在,根据我通过here,tags
引用的文档,在返回时会按特殊顺序排列,但是我对为什么值release-1.3
不是响应中的第一位感到困惑。我想我缺少了一些东西。或者,如果这是预期的顺序,那么我如何实现按date
属性排序的标签,以获得最新的标签。
答案 0 :(得分:0)
因此,我可以通过在属性sort
上使用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'