[英]Using GitHub API to retrieve files with specific extension
I want to get a list of files from given git repository. 我想从给定的git仓库中获取文件列表。 For an example, I want to get all *.js files from a given git repository.
例如,我想从给定的git存储库中获取所有* .js文件。 How can I use GitHub API to satisfy above requirement?
如何使用GitHub API满足上述要求? or is there any way to get the list of *.js files from a git repository?
还是有什么方法可以从git存储库中获取* .js文件列表?
Here, what I did to find out all .js file in my own repository. 在这里,我做了什么以找出我自己的存储库中的所有.js文件。
curl -i "https://api.github.com/search/code?q=extension:js+repo:vnation/NewsAggregator"
source: https://developer.github.com/v3/search/#search-code 来源: https : //developer.github.com/v3/search/#search-code
EDIT 编辑
This is what I did to find out the path of ".classpath" file in the master branch of my repo. 这是我在回购的master分支中查找“ .classpath”文件的路径所要做的。
curl -i "https://api.github.com/repos/vnation/NewsAggregator/contents/.classpath"
SOURCE: https://developer.github.com/v3/repos/contents/#get-contents 消息来源: https : //developer.github.com/v3/repos/contents/#get-contents
However , git response above API with base64 encoded content.
但是 ,git以上的API响应具有base64编码的内容。 So, to get raw data you should use below one.
因此,要获取原始数据,应使用以下一项。
curl -i "https://raw.githubusercontent.com/vnation/NewsAggregator/master/.classpath"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.