github API;返回一个标签数组 [英] github API; returning an array of tags
问题描述
我可以以某种方式使用github API为现有的标签返回一组标签库?
我有一个文件,我定期用版本标签提交。所以我想能够调用github并返回如下内容:
$ tags = $ tags('v1.0 ','v1.1','v2.0','v2.1')
或者甚至可能是一个包含标签和日期的关联数组。
但是,无论如何,我想再打电话给Github并返回这个列表。然后我可以允许用户使用以下github url来选择他们希望看到的版本:
https:// raw.github.com/<username>/<projectname>/<tagname>/<filepath>
有什么建议吗?
Thanks。
您可以使用 GitHub V3 API 并解析结果以构建数组:
$ curl https://api.github.com/repos/VonC/gitolite/git/refs/tags|grep\refs
%总计%收到%Xferd平均速度时间时间时间当前
Dload Upload Total Spent Left Speed
ref:refs / tags / nonstd-path-for-00,6: - : - 0:00:01 - : - : - 0
ref:refs / tags / v0.50,1
ref:refs / tags / v0.55,62
ref:refs / tags / v0.60,
ref:refs / tags / v0.65,
ref:refs / tags / v0.70,62
ref:refs / tags / v0.80,
ref:refs / tags / v0.85,0:
ref:refs / tags /v0.90\"1
ref:refs / tags / v0.95,0:
ref:refs / tags / v1.0, - :
ref:refs / tags / v1.0rc1, -
ref:refs / tags / v1.1,
ref:refs / tags / v1.2 ,
ref: refs / tags / v1.3,
ref:refs / tags / v1.4,
ref:refs / tags / v1.4.1,
ref:refs / tags / v1.4.2,
ref:refs / tags / v1.5,
I was wondering if the following is possible -- and how to do it.
Can I somehow use the github API to return an array of tags for an existing repository?
I have a file that I periodically "commit" with version tags. So I'd like to be able to call github and return something like:
$tags = $tags('v1.0', 'v1.1', 'v2.0', 'v2.1')
Or maybe even an associative array that includes both the tag and the date.
But anyway, I'd like to then call to Github and return this list. Then I can allow the user to select the version of they would like to see using the following github url:
https://raw.github.com/<username>/<projectname>/<tagname>/<filepath>
Any suggestions? Thanks.
You could use the GitHub V3 API and parse the result to build your array:
$ curl https://api.github.com/repos/VonC/gitolite/git/refs/tags|grep "\"refs"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
"ref": "refs/tags/nonstd-path-for-00", 6:--:-- 0:00:01 --:--:-- 0
"ref": "refs/tags/v0.50", 1
"ref": "refs/tags/v0.55",62
"ref": "refs/tags/v0.60",
"ref": "refs/tags/v0.65",
"ref": "refs/tags/v0.70",62
"ref": "refs/tags/v0.80",
"ref": "refs/tags/v0.85",0:
"ref": "refs/tags/v0.90",1
"ref": "refs/tags/v0.95",0:
"ref": "refs/tags/v1.0",-:
"ref": "refs/tags/v1.0rc1",-
"ref": "refs/tags/v1.1",
"ref": "refs/tags/v1.2",
"ref": "refs/tags/v1.3",
"ref": "refs/tags/v1.4",
"ref": "refs/tags/v1.4.1",
"ref": "refs/tags/v1.4.2",
"ref": "refs/tags/v1.5",
这篇关于github API;返回一个标签数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!