【问题标题】:Is it possible to get commits history for one file in github api?是否可以在 github api 中获取一个文件的提交历史记录?
【发布时间】:2017-11-27 10:27:22
【问题描述】:

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

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

但这也无济于事。这至少可能吗?

【问题讨论】:

    标签: github github-api


    【解决方案1】:

    【讨论】:

    【解决方案2】:

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

    {
      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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-05
      • 2018-11-04
      • 2016-06-28
      • 1970-01-01
      • 2013-08-02
      • 2023-01-22
      • 2021-01-06
      相关资源
      最近更新 更多