其他人已经指出了使用 github API 解决此问题的方法。您的问题也留下了仅使用 git 而不是 github 来执行此操作的可能性。 JSON 的优点在于它只是文本,因此您只需使用 git log 即可生成它。
$ echo "[" && git log -n5 --pretty=format:\"%H\", && echo "]"
[
"216e8824cfac3d3a46eac23fb177566829f2f236",
"8b0357b71fa824114f9db96954b364a8f815fd50",
"bd394fd40184df8b22e45fb6aaa1fc1c3c6dc31a",
"c35af70eaedcdd05b56496e555f33c65286e85ba",
"9e65dfd39de1732bc114bee184f595a6f091680c",
]
我知道你最终会需要比这更多的细节,但这是一个起点。
好的,这是另一个例子。这很有趣。
$ echo "[" && git log -n5 --pretty=format:'{ "author": "%an", "subject":"%s" }', && echo "]"
[
{ "author": "Saul Torrell", "subject":"June 21 release - operator systems" },
{ "author": "Saul Torrell", "subject":"Missing topic for june 11 release." },
{ "author": "Saul Torrell", "subject":"June 11 release." },
{ "author": "Saul Torrell", "subject":"new topic." },
{ "author": "Saul Torrell", "subject":"Added extra sauce to the frobnicator." },
]