你可以得到单个提交使用GET /repos/:owner/:repo/commits/:sha
,然后你可以把它用jq
,例如这将打印修改的文件作为平面列表处理:
curl -s https://api.github.com/ENDPOINT | jq -r '.files | .[] | select(.status == "modified") | .filename'
有但一个重要的警告:此过滤器GET查询的结果,其中包含提交的全部内容,这可能是大量数据。我不知道你是否担心这一点。我寻找一种方法来过滤返回的字段,以避免使用不必要的带宽,但我无法在API中找到。
,如果你感兴趣,JSON格式,这样你可以得到更多的细节:
curl -s https://api.github.com/ENDPOINT | jq '[.files | .[] | select(.status == "modified")]'
这将产生的输出是这样的:
[
{
"sha": "564324525eb706f7cc2756ceef8b82cdfeaf270c",
"filename": "README.md",
"status": "modified",
"additions": 1,
"deletions": 0,
"changes": 1,
"blob_url": "https://github.com/janosgyerik/test1/blob/41885b6c8183de3ab5be02884fdcc37d920e41b9/README.md",
"raw_url": "https://github.com/janosgyerik/test1/raw/41885b6c8183de3ab5be02884fdcc37d920e41b9/README.md",
"contents_url": "https://api.github.com/repos/janosgyerik/test1/contents/README.md?ref=41885b6c8183de3ab5be02884fdcc37d920e41b9",
"patch": "@@ -1,3 +1,4 @@\n test1\n =====\n nothing special\n+Sat May 13 00:16:02 CEST 2017"
},
{
"sha": "37a26e04e6bdc55935e00f2a092d936240771aca",
"filename": "index.html",
"status": "modified",
"additions": 1,
"deletions": 0,
"changes": 1,
"blob_url": "https://github.com/janosgyerik/test1/blob/41885b6c8183de3ab5be02884fdcc37d920e41b9/index.html",
"raw_url": "https://github.com/janosgyerik/test1/raw/41885b6c8183de3ab5be02884fdcc37d920e41b9/index.html",
"contents_url": "https://api.github.com/repos/janosgyerik/test1/contents/index.html?ref=41885b6c8183de3ab5be02884fdcc37d920e41b9",
"patch": "@@ -55,3 +55,4 @@\n </div>\n </body>\n </html>\n+"
}
]
谢谢了,将检查在我的情况下,它对带宽有什么影响。 – Nitin