gpt4 book ai didi

github-api - 如何使用 GitHub API v3 判断存储库是事件的还是禁用的?

转载 作者:行者123 更新时间:2023-12-05 05:26:48 24 4
gpt4 key购买 nike

我正在使用 /user/repos?type=member&per_page=100&access_token=MYTOKEN 并返回我所属的所有存储库。

但是,当我转到 github.com/owner_name/repo/branches 时,一些 repo 协议(protocol)被禁用,它说 repo 协议(protocol)被禁用。

但是 API 响应没有给出任何指示。有什么方法可以告诉吗?

最佳答案

我询问了 Github 支持并得到了以下回复:

The API matches the behavior of github.com with regard to disabled repositories. When you sign in and visit https://github.com, you'll see a list of repositories that you have access to under "Your repositories" (on the right-hand side). You should see repo_owner/DISABLED-REPO in that list. If you click on that repository in the list, you should be taken to the page for that repository, but also get a message that the repository has been disabled.

The API provides the same information. If you fetch the list of repositories, the API tells you that you have access to that repository. However, to determine that it has been disabled, you'll need to fetch the repository itself -- there is no special "disabled" attribute when you fetch a list of repositories, which you are doing.

So, try making this request:

https://api.github.com/repos/repo_owner/DISABLED-REPO?access_token=MYTOKEN

You should see a 403 Forbidden status with a helpful message in the body.

Also, I'll pass your question/suggestion to the team to consider including a "disabled" attribute when fetching a list of repositories. However, I can't make any promises about if/when that might happen.

关于github-api - 如何使用 GitHub API v3 判断存储库是事件的还是禁用的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23744959/

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