【问题标题】:Use --name-only option with GitHub API diff media format将 --name-only 选项与 GitHub API 差异媒体格式一起使用
【发布时间】:2017-01-05 22:39:27
【问题描述】:

我正在尝试使用 GitHub API V3 差异媒体类型来检索 HEAD 和特定提交之间的更改文件列表。我只想要文件名。

基本上我想做: git diff HEAD <commit> --name-only

我已经通过发送 GET 请求部分成功了

https://api.github.com/repos/<owner>/<repos>/commits/<sha>

带有以下“接受”标头:

"application/vnd.github.v3.diff"

但是,这给了我完整的差异。有没有办法只检索文件名?

我查阅的文档是https://developer.github.com/v3/media/#commits-commit-comparison-and-pull-requests

【问题讨论】:

    标签: github-api


    【解决方案1】:

    我刚刚在以下链接中找到了有关“比较”资源的文档: https://developer.github.com/v3/repos/commits/#compare-two-commits

    似乎我可以简单地从以下 URL 请求,而不是使用 diff 媒体类型:

    https://api.github.com/repos/<owner>/<repos>/compare/<sha>...master 然后查询响应中的“文件”和“文件名”字段。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-17
      相关资源
      最近更新 更多