我正在使用 GitHub Developer API v2。当前需要从存储库中检索所有文件路径。有没有人有这方面的经验?
最佳答案
作为起点,您可以检查 ls-tree 的输出是什么样的。
但是:
- 对该输出进行一些解析,以便您获得所需的准确结果。
- 它似乎不是递归的!
进入树 GitHub Api V2 is described here .
只有 GitHub Api V3提到一个 ?recursive=1
选项。
tree/show/:user/:repo/:tree_sha
您可以在 this article 中查看示例:
To get a listing of the root tree for the facebox project from our commit listing, we can call this:
$ curl http://github.com/api/v2/yaml/tree/show/defunkt/facebox/f7a5de2e224ec94182a3c2c081f4e7f4df70da4
---
tree:
- name: .gitignore
sha: e43b0f988953ae3a84b00331d0ccf5f7d51cb3cf
mode: "100644"
type: blob
- name: README.txt
sha: d4fc2d5e810d9b4bc1ce67702603080e3086a4ed
mode: "100644"
type: blob
- name: b.png
sha: f184e6269b343014f58694093b55558dd5dde193
mode: "100644"
type: blob
- name: bl.png
sha: f6271859d51654b6fb2719df5fe192c8398ecefc
mode: "100644"
type: blob
关于c# - 如何从 Github 存储库获取所有文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8034945/