Is it possible to get commits history for one file in github api?

谁说我不能喝 提交于 2019-12-28 11:54:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!