Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GitHub通知-失败的拉取请求_Git_Github_Github Api - Fatal编程技术网

GitHub通知-失败的拉取请求

GitHub通知-失败的拉取请求,git,github,github-api,Git,Github,Github Api,我是工作中几个大型存储库的成员,希望能够设置每日检查(可能是电子邮件/slackbot),向我发送我已打开的未完成拉取请求以及它们仍然打开的原因。在合并PR之前,我们有3个检查:Linter检查、代码检查和CI。我想看看这3个检查中哪一个失败了(或者在代码审查的情况下还没有完成) 这可能吗?是的,这是可能的 看一看 获取存储库的打开PRs列表: 您对打开的PRs感兴趣,因此使用设置为open和head的state参数按用户引用进行过滤 CI检查称为“状态” 其中:ref是最新提交的哈希(分支

我是工作中几个大型存储库的成员,希望能够设置每日检查(可能是电子邮件/slackbot),向我发送我已打开的未完成拉取请求以及它们仍然打开的原因。在合并PR之前,我们有3个检查:Linter检查、代码检查和CI。我想看看这3个检查中哪一个失败了(或者在代码审查的情况下还没有完成)

这可能吗?

是的,这是可能的

看一看

获取存储库的打开PRs列表:

您对打开的PRs感兴趣,因此使用设置为
open
head
state
参数按用户引用进行过滤

CI检查称为“状态”

其中
:ref
是最新提交的哈希(分支中的最新提交)

最新提交SHA值可在
/pulls
响应中找到:

[
{
 "head": {
      "label": "new-topic",
      "ref": "new-topic",
      "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
}
]
结合这些,您可以在早上轮询回购协议,并构建一个相当简单的Slack/Email bot。

GitHub应该可以很好地用于此用例

下面是一个查询,它一次检索存储库字段、请购单字段和合并状态(按上下文分组):

query { repository(owner: "github", name:"fetch") 
  { 
    name
    pullRequests(first: 3, states: OPEN, orderBy: {field: UPDATED_AT, direction: DESC}) {
      nodes {
        url
        author {
          ... on User {
            login name
          }
        }        
        mergeable
        baseRefName
        headRefName
        title
        milestone { title }
        labels(first: 100) { nodes{name} }
        ... on PullRequest {
          pullRequestcommits: commits(last: 1) {
            totalCount
            nodes {
              commit {
                #url 
                status { state contexts { context description createdAt targetUrl } }
              }
            }
          }
        }
      }
    } 
  }
}
上面的示例查询返回三个最近更新的拉取请求,并对存储库进行状态检查:

{
  "data": {
    "repository": {
      "name": "fetch",
      "pullRequests": {
        "nodes": [
          {
            "url": "https://github.com/github/fetch/pull/616",
            "author": {
              "login": "jayphelps",
              "name": "Jay Phelps"
            },
            "mergeable": "MERGEABLE",
            "baseRefName": "master",
            "headRefName": "umd",
            "title": "build/distribute as UMD",
            "milestone": null,
            "labels": {
              "nodes": []
            },
            "pullRequestcommits": {
              "totalCount": 1,
              "nodes": [
                {
                  "commit": {
                    "status": {
                      "state": "SUCCESS",
                      "contexts": [
                        {
                          "context": "continuous-integration/travis-ci/pr",
                          "description": "The Travis CI build passed",
                          "createdAt": "2018-04-09T17:39:00Z",
                          "targetUrl": "https://travis-ci.org/github/fetch/builds/364229647?utm_source=github_status&utm_medium=notification"
                        }
                      ]
                    }
                  }
                }
              ]
            }
          },
          {
            "url": "https://github.com/github/fetch/pull/592",
            "author": {
              "login": "jamesplease",
              "name": "James"
            },
            "mergeable": "MERGEABLE",
            "baseRefName": "master",
            "headRefName": "abort-polyfill",
            "title": "Support abort API",
            "milestone": null,
            "labels": {
              "nodes": []
            },
            "pullRequestcommits": {
              "totalCount": 23,
              "nodes": [
                {
                  "commit": {
                    "status": {
                      "state": "SUCCESS",
                      "contexts": [
                        {
                          "context": "GitHub CLA",
                          "description": "@jmeas has accepted the GitHub Contributor License Agreement.",
                          "createdAt": "2018-02-04T18:41:33Z",
                          "targetUrl": "https://cla.github.com/github/fetch/accept/jmeas"
                        },
                        {
                          "context": "continuous-integration/travis-ci/pr",
                          "description": "The Travis CI build passed",
                          "createdAt": "2018-02-04T18:42:51Z",
                          "targetUrl": "https://travis-ci.org/github/fetch/builds/337277553?utm_source=github_status&utm_medium=notification"
                        }
                      ]
                    }
                  }
                }
              ]
            }
          },
          {
            "url": "https://github.com/github/fetch/pull/575",
            "author": {
              "login": "CrOrc",
              "name": "Roman Yakubuk"
            },
            "mergeable": "MERGEABLE",
            "baseRefName": "master",
            "headRefName": "CrOrc-fix-resolve-IE-11",
            "title": "Fix issue #533",
            "milestone": null,
            "labels": {
              "nodes": []
            },
            "pullRequestcommits": {
              "totalCount": 1,
              "nodes": [
                {
                  "commit": {
                    "status": {
                      "state": "SUCCESS",
                      "contexts": [
                        {
                          "context": "GitHub CLA",
                          "description": "@CrOrc has accepted the GitHub Contributor License Agreement.",
                          "createdAt": "2017-10-27T16:29:56Z",
                          "targetUrl": "https://cla.github.com/github/fetch/accept/CrOrc"
                        },
                        {
                          "context": "continuous-integration/travis-ci/pr",
                          "description": "The Travis CI build passed",
                          "createdAt": "2017-10-23T14:07:55Z",
                          "targetUrl": "https://travis-ci.org/github/fetch/builds/291563522?utm_source=github_status&utm_medium=notification"
                        }
                      ]
                    }
                  }
                }
              ]
            }
          }
        ]
      }
    }
  }
}
然后可以将graphql json展平为CSV报告:

您可以扩展上述查询以从多个存储库(例如,从属于您组织的所有存储库)获取请求

query { organization(login: "github") {
  repositories(first: 5) {
    nodes {
    # serialize repo and PR fields as displayed above
  }
}

你查过他们的帮助区了吗?
query { repository(owner: "github", name:"fetch") 
  { 
    name
    pullRequests(first: 3, states: OPEN, orderBy: {field: UPDATED_AT, direction: DESC}) {
      nodes {
        url
        author {
          ... on User {
            login name
          }
        }        
        mergeable
        baseRefName
        headRefName
        title
        milestone { title }
        labels(first: 100) { nodes{name} }
        ... on PullRequest {
          pullRequestcommits: commits(last: 1) {
            totalCount
            nodes {
              commit {
                #url 
                status { state contexts { context description createdAt targetUrl } }
              }
            }
          }
        }
      }
    } 
  }
}
{
  "data": {
    "repository": {
      "name": "fetch",
      "pullRequests": {
        "nodes": [
          {
            "url": "https://github.com/github/fetch/pull/616",
            "author": {
              "login": "jayphelps",
              "name": "Jay Phelps"
            },
            "mergeable": "MERGEABLE",
            "baseRefName": "master",
            "headRefName": "umd",
            "title": "build/distribute as UMD",
            "milestone": null,
            "labels": {
              "nodes": []
            },
            "pullRequestcommits": {
              "totalCount": 1,
              "nodes": [
                {
                  "commit": {
                    "status": {
                      "state": "SUCCESS",
                      "contexts": [
                        {
                          "context": "continuous-integration/travis-ci/pr",
                          "description": "The Travis CI build passed",
                          "createdAt": "2018-04-09T17:39:00Z",
                          "targetUrl": "https://travis-ci.org/github/fetch/builds/364229647?utm_source=github_status&utm_medium=notification"
                        }
                      ]
                    }
                  }
                }
              ]
            }
          },
          {
            "url": "https://github.com/github/fetch/pull/592",
            "author": {
              "login": "jamesplease",
              "name": "James"
            },
            "mergeable": "MERGEABLE",
            "baseRefName": "master",
            "headRefName": "abort-polyfill",
            "title": "Support abort API",
            "milestone": null,
            "labels": {
              "nodes": []
            },
            "pullRequestcommits": {
              "totalCount": 23,
              "nodes": [
                {
                  "commit": {
                    "status": {
                      "state": "SUCCESS",
                      "contexts": [
                        {
                          "context": "GitHub CLA",
                          "description": "@jmeas has accepted the GitHub Contributor License Agreement.",
                          "createdAt": "2018-02-04T18:41:33Z",
                          "targetUrl": "https://cla.github.com/github/fetch/accept/jmeas"
                        },
                        {
                          "context": "continuous-integration/travis-ci/pr",
                          "description": "The Travis CI build passed",
                          "createdAt": "2018-02-04T18:42:51Z",
                          "targetUrl": "https://travis-ci.org/github/fetch/builds/337277553?utm_source=github_status&utm_medium=notification"
                        }
                      ]
                    }
                  }
                }
              ]
            }
          },
          {
            "url": "https://github.com/github/fetch/pull/575",
            "author": {
              "login": "CrOrc",
              "name": "Roman Yakubuk"
            },
            "mergeable": "MERGEABLE",
            "baseRefName": "master",
            "headRefName": "CrOrc-fix-resolve-IE-11",
            "title": "Fix issue #533",
            "milestone": null,
            "labels": {
              "nodes": []
            },
            "pullRequestcommits": {
              "totalCount": 1,
              "nodes": [
                {
                  "commit": {
                    "status": {
                      "state": "SUCCESS",
                      "contexts": [
                        {
                          "context": "GitHub CLA",
                          "description": "@CrOrc has accepted the GitHub Contributor License Agreement.",
                          "createdAt": "2017-10-27T16:29:56Z",
                          "targetUrl": "https://cla.github.com/github/fetch/accept/CrOrc"
                        },
                        {
                          "context": "continuous-integration/travis-ci/pr",
                          "description": "The Travis CI build passed",
                          "createdAt": "2017-10-23T14:07:55Z",
                          "targetUrl": "https://travis-ci.org/github/fetch/builds/291563522?utm_source=github_status&utm_medium=notification"
                        }
                      ]
                    }
                  }
                }
              ]
            }
          }
        ]
      }
    }
  }
}
query { organization(login: "github") {
  repositories(first: 5) {
    nodes {
    # serialize repo and PR fields as displayed above
  }
}