使用 Github API(无本地 git 命令),是否可以比较分支以查看它在默认分支之前是否有任何更改?
我正在构建一个审核工具,并希望确定要关闭的候选分支,因为它们的所有更改都存在于默认分支中。
I want the same information that drives the charts on the branches page:
(See https://github.com/octokit/octokit.rb/branches https://github.com/octokit/octokit.rb/branches)
是否可以纯粹通过 Github API 获取这些信息?
你可以:
使用获取默认分支https://api.github.com/repos/octokit/octokit.rb https://api.github.com/repos/octokit/octokit.rb
使用以下命令将指定分支与默认分支进行比较比较两个提交 API https://developer.github.com/v3/repos/commits/#compare-two-commits并提取ahead_by
& behind_by
字段。
在这种情况下,它将是:https://api.github.com/repos/octokit/octokit.rb/compare/kytrinyx/generator/spike...master https://api.github.com/repos/octokit/octokit.rb/compare/kytrinyx/generator/spike...master
使用示例bash /questions/tagged/bash, curl /questions/tagged/curl & jq /questions/tagged/jq :
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'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)