你可以得到單個提交使用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