Github API:如何找到拉请求的分支? [英] Github API: how to find the branches of a pull request?

查看:304
本文介绍了Github API:如何找到拉请求的分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Github API(v3)允许您获取pull请求的列表,并获取有关单个pull请求的更多详细信息。我似乎无法找到的是拉取请求来自的分支的名称,以及拉取请求所建议的代码被合并到的分支。



使用Github API,您如何确定牵扯请求中的分支? / div>


  1. 访问合并请求网址。让我们使用 https://api.github.com/repos/github/gitignore/pulls/566 为例。


  2. 解析JSON对象。






合并请求引用两个分支。 base 分支是合并目标。通常这是存储库的 master 分支。



  • base.label github:master ,意思是它是 master 分支,用于> github / gitignore

  • base.ref 是分行名称master。
  • base.sha 是该分支的当前 SHA



分支是你合并到 base 中的内容。



  • head.label fidelski :add-obvious-autotools-files ,意思是 fidelski / gitignore的 add-obvious-autotools-files 分支

  • head.ref 是分支名称 add-obvious-autotools -files

  • head.sha 是当前的 SHA


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. 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.

这篇关于Github API:如何找到拉请求的分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆