Как узнать, активен репозиторий или отключен, используя GitHub API v3?

Я использую /user/repos?type=member&per_page=100&access_token=MYTOKEN, и это возвращает все репозитории, членом которых я являюсь.

Однако некоторые репозитории disabled, когда я перехожу к github.com/owner_name/repo/branches, там написано, что репозиторий отключен.

Но ответ API ничего не говорит об этом. Есть ли способ сказать?


person Shamoon    schedule 19.05.2014    source источник
comment
Можете ли вы поделиться примером конкретного репозитория, демонстрирующего такое поведение?   -  person jasonrudolph    schedule 20.05.2014


Ответы (1)


Я спросил Github support и получил следующий ответ:

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.
person Shamoon    schedule 20.05.2014