【问题标题】:GitHub Rest API similar git rev-list commandGitHub Rest API 类似 git rev-list 命令
【发布时间】:2021-10-23 23:54:33
【问题描述】:

我得到了一个 repo 的所有提交:

curl  -I -k -u ${api_user}:${api_token} "${api_url}/commits?sha=${api_branch}&per_page=1" | sed -n '/^[Ll]ink:/ s/.*"next".*page=\([0-9]*\).*"last".*/\1/p'

git rev-list 与 GitHub Rest API 和 curl 有类似的方法吗?

提前致谢!

【问题讨论】:

  • 我有点困惑:你是在寻找一个 git rev-list 命令来完成你的 curl 所做的事情,还是在寻找一个 curl 操作来完成 git rev-list 所做的事情?

标签: git github


【解决方案1】:

GitHub API v3 Commits API 是最接近的:

GET /repos/{owner}/{repo}/commits

它可能与您使用的完全相同,具体取决于${api_url}
git rev-list 一样,它包含一个提交引用,列表从该引用开始。
还有一个路径,仅列出修改给定<paths> 的提交。

但是,它不会允许更复杂的提交规范,例如 git rev-list foo bar ^baz,它列出了可以从 foobar 访问但不能从 baz 访问的所有提交。

为此,您需要一个GraphQL query,使用Commit object,例如[那些] examples.6

【讨论】:

  • 好吧,也许我可以使用 curl 获取所有提交并提取有 2 个以上父母的提交?
  • @RomanBürkle 是:将列出从起点可到达的任何提交,包括具有两个以上父级的提交。
猜你喜欢
  • 2020-07-17
  • 2020-11-26
  • 2021-01-31
  • 1970-01-01
  • 2019-09-20
  • 1970-01-01
  • 1970-01-01
  • 2021-06-10
  • 1970-01-01
相关资源
最近更新 更多