【问题标题】:using graphql github api to get commit information by Id使用graphql github api通过Id获取提交信息
【发布时间】:2019-12-06 09:20:01
【问题描述】:

鉴于我已经拥有提交 ID,我想获取特定提交的提交详细信息

例如,如果我知道提交 id 是 12762b76cba8ac4623a6c16e1fe60efafa3b7d1c 和 repo 是 ruby/ruby

如何获得提交日期和作者电子邮件?

【问题讨论】:

    标签: graphql github-api github-graphql


    【解决方案1】:

    您可以尝试使用cursor 作为边缘类型,如this thread

    {
      repository(owner: "octocat", name: "Hello-World") {
        first: object(expression: "master") {
          ... on Commit {
            history(path: "README", last: 1, before: "762941318ee16e59dabbacb1b4049eec22f0d303 1") {
              edges {
                node { 
                  committedDate 
                  oid
                  author
                  {  
                    email
                  }
                } 
              }
            }
          }
        }
      }
    }
    

    你可以使用这个资源管理器https://developer.github.com/v4/explorer/进行测试

    【讨论】:

    • 只要您不需要最后一次提交,它就可以工作。如果你去developer.github.com/v4/explorer 并使用 7fd1a60b01f91b314f59955a4e4d4e80d8edf11d 它会给你 76294 提交。发生这种情况是因为我们使用游标在 7fd1 之后获取提交。
    • @eiu165 你能用你最终使用的实际查询来编辑这个答案吗?
    • @eiu165 非常感谢。显然,您没有使用“光标”边缘类型。
    猜你喜欢
    • 1970-01-01
    • 2017-11-27
    • 2019-12-11
    • 2021-02-11
    • 2019-03-25
    • 2020-01-12
    • 2022-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多