gpt4 book ai didi

github - 如何从 Github API 获取最新的 "stable" repo 版本?

转载 作者:行者123 更新时间:2023-12-04 05:11:36 27 4
gpt4 key购买 nike

Github 的 tag method返回推送到您的仓库的所有标签的列表,最新标签列在顶部。这是一个示例调用:https://api.github.com/repos/ff0000/rosy/tags生成以下 json 对象。

[{
name: "rbp-folder-rename",
zipball_url: "https://api.github.com/repos/ff0000/rosy/zipball/rbp-folder-rename",
tarball_url: "https://api.github.com/repos/ff0000/rosy/tarball/rbp-folder-rename",
commit: {
sha: "09ebda2678d932a005fc86ab78f6c04eebdcd50d",
url: "https://api.github.com/repos/ff0000/rosy/commits/09ebda2678d932a005fc86ab78f6c04eebdcd50d"
}
},
{
name: "2.0.10",
zipball_url: "https://api.github.com/repos/ff0000/rosy/zipball/2.0.10",
tarball_url: "https://api.github.com/repos/ff0000/rosy/tarball/2.0.10",
commit: {
sha: "fe284c7d461107d9d08d2d4dcb676759f9485fc1",
url: "https://api.github.com/repos/ff0000/rosy/commits/fe284c7d461107d9d08d2d4dcb676759f9485fc1"
}
},

// ....

{
name: "2.1.5",
zipball_url: "https://api.github.com/repos/ff0000/rosy/zipball/2.1.5",
tarball_url: "https://api.github.com/repos/ff0000/rosy/tarball/2.1.5",
commit: {
sha: "db92baa49657b3c3d27b1475c415c19525cb2118",
url: "https://api.github.com/repos/ff0000/rosy/commits/db92baa49657b3c3d27b1475c415c19525cb2118"
}
}]

问题

  1. 此列表似乎在顶部有最新标签,然后是按时间倒序列出的先前标签的历史记录。为什么?第一个结果的顺序与其余结果的顺序不同,这似乎很奇怪,也许我读错了?
  2. 有没有办法以编程方式检索仅应用于 master 分支的最新版本?我想以编程方式检索存储库的最新稳定版本。

任何帮助/见解将不胜感激。

最佳答案

获取最新版本号:

https://api.github.com/repos/user/repo/releases/latest

例如,对于此 repo ( https://github.com/pyIDM/PyIDM),您可以使用以下网址:

https://api.github.com/repos/pyidm/pyidm/releases/latest

你会得到一个带有 tag_name=最新版本的 json 文件

关于github - 如何从 Github API 获取最新的 "stable" repo 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14866528/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com