the*_*ven 5 github github-api octokit
使用 Github API(无本地 git 命令),是否可以比较分支以查看它在默认分支之前是否有任何更改?
我正在构建一个审核工具,并希望确定要关闭的候选分支,因为它们的所有更改都存在于默认分支中。
我想要驱动分支页面上的图表的相同信息:
(参见https://github.com/octokit/octokit.rb/branches)
是否可以纯粹通过 Github API 获取这些信息?
你可以:
使用比较两个提交 API和提取ahead_by&字段将指定分支与默认分支进行比较behind_by。
在这种情况下,它将是: https://api.github.com/repos/octokit/octokit.rb/compare/kytrinyx/generator/spike...master
branch=kytrinyx/generator/spike
default_branch=$(curl -s "https://api.github.com/repos/octokit/octokit.rb" | jq -r '.default_branch')
curl -s "https://api.github.com/repos/octokit/octokit.rb/compare/$branch...$default_branch" | \
jq -r '.ahead_by, .behind_by'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1904 次 |
| 最近记录: |