问题
I would like to get all commit messages for separate file in github REST api. But all I got - only to get all commits for separate branch. Then I tried to get following:
http://api.github.com/users/<username>/<project>/commits/<branch>/<path/to/file>
But that didn't help also. Is this at least possible?
回答1:
Try this (as described in the API docs here):
http://api.github.com/repos/:owner/:repo/commits?path=PATH_TO_FILE
e.g.
https://api.github.com/repos/izuzak/pmrpc/commits?path=README.markdown
回答2:
Using GraphQL API v4, for a file on the default branch, it would be :
{
repository(owner: "izuzak", name: "pmrpc") {
defaultBranchRef{
target {
...on Commit{
history(first:100,path: "README.markdown"){
nodes {
author {
email
}
message
oid
}
}
}
}
}
}
}
Try it in the explorer
来源:https://stackoverflow.com/questions/15831313/is-it-possible-to-get-commits-history-for-one-file-in-github-api