【问题标题】:GitHub API: "compare two commits" unclearGitHub API:“比较两个提交”不清楚
【发布时间】:2020-10-23 16:18:08
【问题描述】:

上下文

我正在制作一个使用 GitHub API (Useful Forks) 的工具。我目前正在尝试了解我使用compare 2 commits api 看到的行为。我已经阅读了以下阅读材料:

  1. GitHub API compare 2 commits documentation
  2. StackOverflow 问题 #1:GitHub API - how to compare 2 commits
  3. StackOverflow 问题 #2:Github Comparison View for 2 branches is incorrect?

但我还是很疑惑……

问题

可重现的步骤:

  1. 确认此父存储库存在:https://github.com/yellowstonegames/SquidLib/network/members
  2. 确认这是它的一个分支:https://github.com/manderin87/SquidLib
  3. 确认 GitHub 承认它是父 repo 的 behindahead
  4. 确认调用 GitHub API 来比较父分支和分支的 master 分支似乎不起作用:https://api.github.com/repos/yellowstonegames/SquidLib/compare/master...manderin87:master

回复是:

{
  "message": "No common ancestor between master and manderin87:master.",
  "documentation_url": "https://docs.github.com/rest/reference/repos#compare-two-commits"
}

我不确定我是否理解这是否是预期的行为。 (我在哪里可以找到所有可能的错误消息的列表,以及针对该特定端点触发它们的原因?)

问题

我应该如何获得上面屏幕截图中给出的数字? (aheadbehind

补充问题

我发现 所有 我正在为其进行此 API 调用的分支没有返回错误 恰好 1379 次提交在原始存储库后面是可疑的。你可以通过我的工具看到:https://useful-forks.github.io/?repository=yellowstonegames/SquidLib

再一次,这可能是因为我对这个 api 调用应该返回什么缺乏了解?

【问题讨论】:

    标签: git github github-api


    【解决方案1】:

    master 的历史记录中有多少次针对此特定 repo 提交?

    您描述的元素可能与对原始回购历史的批量重写相一致(例如git filter-branch 操作)。

    例如,检查 sha1 以了解原始存储库及其其中一个分支中的第一次提交。


    使用本地 git 命令:您可以使用 git rev-list --count a..b (resp b..a) 来查看 ba 的前面(后面)有多少提交。

    即使ab 没有共同的历史记录,a..b 也能正常工作。

    另一方面,git rev-list a...b 会在 ab 之间搜索合并基,如果没有则将失败。

    我不知道使用什么 API 来匹配 git rev-list a..b,也许“列表提交”(在您链接的文档中提到)会允许它。

    【讨论】:

    • 我现在可以确认原始存储库确实使用了git filter-branch。不错的收获。
    猜你喜欢
    • 2018-04-17
    • 1970-01-01
    • 2023-01-25
    • 1970-01-01
    • 2017-05-09
    • 2012-09-14
    • 2022-10-14
    • 2018-10-08
    • 2013-01-03
    相关资源
    最近更新 更多