如何获取repo中所有文件的下载链接?

问题描述 投票:0回答:1

使用以下命令,我可以获取 GitHub 存储库上的文件的

download_url
,但它不包括文件夹内的文件:

curl -H "Authorization: token ghp_..." -H "Accept: application/vnd.github.v3.raw" -L "https://api.github.com/repos/<USER>/<REPO>/contents"

在四处搜索时,我发现了这个答案,以下命令递归地列出了所有文件,但它不包括

download_url

curl -H "Authorization: token ghp_..." -H "Accept: application/vnd.github.v3.raw" -L "https://api.github.com/repos/<USER>/<REPO>/git/trees/main?recursive=1"

我如何获得存储库中

download_url
ALL文件?

github github-api git-api
1个回答
0
投票

使用从

path
端点返回的对象的“
/repos/{owner}/{repo}/git/trees/{tree_sha}
”成员构造 download_url。

模板看起来是

https://raw.githubusercontent.com/{owner}/{repo}/{branch/commit-sha/tree-sha}/{path}

© www.soinside.com 2019 - 2024. All rights reserved.