使用 Github API(没有本地 git 命令),是否可以比较一个分支以查看它是否在默认分支之前有任何更改?
我正在构建一个审计工具,并想确定哪些分支是要关闭的候选分支,因为它们的所有更改都存在于默认分支中。
我想要驱动分支页面上的图表的相同信息:
(见 https://github.com/octokit/octokit.rb/branches)
是否可以纯粹使用 Github API 获取此信息?
最佳答案
你可以:
ahead_by
& behind_by
领域。 在这种情况下,它将是:
https://api.github.com/repos/octokit/octokit.rb/compare/kytrinyx/generator/spike...master
使用 bash 的示例, curl & 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'
关于github - 使用 Github API 是否可以确定一个分支是否在默认分支之前?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51569686/