使用 GitHub API 检索具有特定扩展名的文件

Mat*_*thu 4 javascript github

我想从给定的 git 存储库中获取文件列表。例如,我想从给定的 git 存储库中获取所有 *.js 文件。如何使用 GitHub API 来满足上述要求?或者有什么方法可以从 git 存储库中获取 *.js 文件列表?

Vis*_*tel 5

在这里,我做了什么来找出我自己的存储库中的所有.js文件。

curl -i "https://api.github.com/search/code?q=extension:js+repo:vnation/NewsAggregator"
Run Code Online (Sandbox Code Playgroud)

来源:https : //developer.github.com/v3/search/#search-code

编辑

这就是我在我的 repo 的 master 分支中找出“.classpath”文件的路径所做的工作。

curl -i "https://api.github.com/repos/vnation/NewsAggregator/contents/.classpath"
Run Code Online (Sandbox Code Playgroud)

来源:https : //developer.github.com/v3/repos/contents/#get-contents

但是,使用 base64 编码的内容对 API 上方的 git 响应进行响应。因此,要获取原始数据,您应该使用以下数据。

curl -i "https://raw.githubusercontent.com/vnation/NewsAggregator/master/.classpath"
Run Code Online (Sandbox Code Playgroud)