使用 Github API 是否可以确定某个分支是否位于默认分支之前?

the*_*ven 5 github github-api octokit

使用 Github API(无本地 git 命令),是否可以比较分支以查看它在默认分支之前是否有任何更改?

我正在构建一个审核工具,并希望确定要关闭的候选分支,因为它们的所有更改都存在于默认分支中。

我想要驱动分支页面上的图表的相同信息: 分支有 (参见https://github.com/octokit/octokit.rb/branches

是否可以纯粹通过 Github API 获取这些信息?

Ber*_*tel 6

你可以:

在这种情况下,它将是: 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)