是否可以在 github api 中获取一个文件的提交历史记录?

问题描述 投票:0回答:2

我想获取 github REST api 中单独文件的所有提交消息。但我所得到的只是为了获得单独分支的所有提交。然后我尝试得到以下内容:

http://api.github.com/users/<username>/<project>/commits/<branch>/<path/to/file>

但这也没有帮助。这至少是可能的吗?

github github-api
2个回答
41
投票

尝试一下(如 API 文档此处中所述):

http://api.github.com/repos/:owner/:repo/commits?path=PATH_TO_FILE

例如

https://api.github.com/repos/izuzak/pmrpc/commits?path=README.markdown


额外:从特定分支获取一个文件的提交历史记录


10
投票

使用 GraphQL API v4,对于默认分支上的文件,它将是:

{
  repository(owner: "izuzak", name: "pmrpc") {
    defaultBranchRef{
      target {
        ...on Commit{
            history(first:100,path: "README.markdown"){
            nodes {
              author {
                email
              }
              message
              oid
            }
          }
        }
      }
    }
  }
}

在资源管理器中尝试一下

© www.soinside.com 2019 - 2024. All rights reserved.