我想获取 github REST api 中单独文件的所有提交消息。但我所得到的只是为了获得单独分支的所有提交。然后我尝试得到以下内容:
http://api.github.com/users/<username>/<project>/commits/<branch>/<path/to/file>
但这也没有帮助。这至少是可能的吗?
尝试一下(如 API 文档此处中所述):
http://api.github.com/repos/:owner/:repo/commits?path=PATH_TO_FILE
例如
https://api.github.com/repos/izuzak/pmrpc/commits?path=README.markdown
额外:从特定分支获取一个文件的提交历史记录
https://api.github.com/repos/izuzak/pmrpc/git/refs
object.sha
,例如refs/heads/gh-pages
sha=HASH
参数发出请求:
https://api.github.com/repos/izuzak/pmrpc/commits?sha=0a8e26a92ee3101803314ee7dea6c6057ff2b862&path=apidocs.markdown
使用 GraphQL API v4,对于默认分支上的文件,它将是:
{
repository(owner: "izuzak", name: "pmrpc") {
defaultBranchRef{
target {
...on Commit{
history(first:100,path: "README.markdown"){
nodes {
author {
email
}
message
oid
}
}
}
}
}
}
}