GitHub API为什么不返回存储库的所有分支?

正如标题所说。我正面临为什么使用此命令在GitHub上的this镜像不会在终端中显示输出的问题:

wget --no-check-cert -q -O - "http://api.github.com/repos/bminor/glibc/branches" | grep release

但是在GitHub上有例如:

GitHub API为什么不返回存储库的所有分支?

pu1188 回答:GitHub API为什么不返回存储库的所有分支?

响应为paginated。如果您查看响应标题:

Link: <https://api.github.com/repositories/13868694/branches?page=2>; rel="next",<https://api.github.com/repositories/13868694/branches?page=10>; rel="last"

您将看到第10页,共1页。您可以使用查询字符串参数将每页的记录数增加到100:

curl -Lv 'http://api.github.com/repos/bminor/glibc/branches?per_page=100'

但是您仍然需要获取其他页面;使用page查询字符串参数选择所需的页面,例如:

$ curl -sL 'http://api.github.com/repos/bminor/glibc/branches?page=2&per_page=100' \
      | jq -r '.[] | select(.name | contains("release")).name'
hjl/release/2.20/master
hjl/x32/release/2.12
hjl/x32/release/2.15
本文链接:https://www.f2er.com/3135769.html

大家都在问