【问题标题】:Using the Github API is it possible to determine if a branch is ahead of the default branch?使用 Github API 是否可以确定一个分支是否在默认分支之前?
【发布时间】:2019-01-05 06:30:06
【问题描述】:

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

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

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

是否可以完全使用 Github API 获取这些信息?

【问题讨论】:

    标签: github github-api octokit


    【解决方案1】:

    你可以:

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

    【讨论】:

      猜你喜欢
      • 2020-05-26
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2013-11-25
      • 2019-06-26
      • 1970-01-01
      • 2018-12-30
      • 2020-08-11
      相关资源
      最近更新 更多