Get pull requests for private github repository via API

こ雲淡風輕ζ 提交于 2019-12-10 19:02:26

问题


I want to programmatically get a list of open pull requests for a specific private github repository - ours, as it turns out. I assume I can only do this via the github api (http://developer.github.com/) - feel free to tell me there's another way - but I can't figure out whether the API allows this, either. The given API calls seem to assume the target repository is public, which ours is not. I would have thought there would be a way to authenticate as a user of the given repository via ssh key (the same way committing works), but I don't see anything to that effect. All in all I'm puzzled and not at all sure I can actually do this. Am I missing a crucial part of the documentation, or is there possibly some alternative I can leverage?


回答1:


Yes, the GitHub Pull Requests API supports private repos also. You just need to authenticate or you will get an error saying that the repository does not exist.

Example using curl and basic authentication:

curl -u "username" https://api.github.com/repos/:user/:repo/pulls

This will then prompt you for your password and return a list of pull requests as described in the API docs.

Also check out the docs on authentication: http://developer.github.com/v3/#authentication



来源:https://stackoverflow.com/questions/13997638/get-pull-requests-for-private-github-repository-via-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!