Github API: how to find the branches of a pull request?

独自空忆成欢 提交于 2019-12-18 12:56:15

问题


The Github API (v3) allows you to get a listing of pull requests, and get more details on an individual pull request. What I can't seem to find is the name of the branch the pull request is coming from and the branch the pull request is suggesting the code be merged into.

Using the Github API how do you determine the branches involved in a pull request?


回答1:


  1. Access a Pull Request URL. Let's use https://api.github.com/repos/github/gitignore/pulls/566 as an example.

  2. Parse the JSON object.


A Pull Request references two branches. The base branch is the merge target. Usually this is the master branch of the repository.

  • base.label is github:master, meaning it's the master branch for > github/gitignore.
  • base.ref is the branch name "master".
  • base.sha is the current SHA of that branch.

The head branch is what you're merging into the base.

  • head.label is fidelski:add-obvious-autotools-files, meaning it's the add-obvious-autotools-files branch for fidelski/gitignore.
  • head.ref is the branch name add-obvious-autotools-files.
  • head.sha is the current SHA of that branch.


来源:https://stackoverflow.com/questions/15096331/github-api-how-to-find-the-branches-of-a-pull-request

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