我想知道以下是否可行 - 以及如何做到这一点.
我可以以某种方式使用github API返回现有存储库的标签数组吗?
我有一个文件,我定期"提交"版本标签.所以我希望能够调用github并返回类似的内容:
$tags = $tags('v1.0', 'v1.1', 'v2.0', 'v2.1')
或者甚至可能是包含标记和日期的关联数组.
但无论如何,我想打电话给Github并返回此列表.然后我可以允许用户使用以下github url选择他们想要查看的版本:
https://raw.github.com// / /
有什么建议?谢谢.
您可以使用GitHub V3 API并解析结果来构建您的数组:
$ 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",