是否可以通过 GitHub API 查明问题是否已通过拉取请求关闭

2024-01-21

I'm using github-script https://github.com/marketplace/actions/github-script for GitHub actions, which allows you to easily access GitHub API. I'm trying to check if an issue has not been closed by clicking on the "close button", that is, via a commit or via merging a pull request that includes a closing commit (or closes in the PR body). However, there does not seem an easy way to do that. This is the event information the GitHub API returns: enter image description here

  • 如果问题已从提交中关闭,则会添加 commit_id
  • 如果问题已从 GitHub 应用程序关闭(显然,这不包括网络),performed_via_github_app被设置为非空。

然而,显然,似乎没有一种特殊的方式来表明问题已通过拉取请求关闭。或者是吗?


可以使用以下命令检查特定问题是否已通过拉取请求、提交或按钮/API 关闭GraphQL API https://docs.github.com/en/free-pro-team@latest/graphql with timelineItems https://docs.github.com/en/free-pro-team@latest/graphql/reference/unions#issuetimelineitems并根据状态过滤事件CLOSED_EVENT :

{
  repository(name: "material-ui", owner: "mui-org") {
    issue(number: 19641) {
      timelineItems(itemTypes: CLOSED_EVENT, last: 1) {
        nodes {
          ... on ClosedEvent {
            createdAt
            closer {
               __typename
              ... on PullRequest {
                baseRefName
                baseRepository {
                  nameWithOwner
                }
                headRefName
                headRepository {
                  nameWithOwner
                }
              }
            }
          }
        }
      }
    }
  }
}

在资源管理器中尝试一下 https://developer.github.com/v4/explorer/?query=%7B%0A%20%20repository%28name%3A%20%22material-ui%22%2C%20owner%3A%20%22mui-org%22%29%20%7B%0A%20%20%20%20issue%28number%3A%2019641%29%20%7B%0A%20%20%20%20%20%20timelineItems%28itemTypes%3A%20CLOSED_EVENT%2C%20last%3A%201%29%20%7B%0A%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20...%20on%20ClosedEvent%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20createdAt%0A%20%20%20%20%20%20%20%20%20%20%20%20closer%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20...%20on%20PullRequest%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20baseRefName%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20baseRepository%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nameWithOwner%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20headRefName%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20headRepository%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nameWithOwner%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A

The closer字段包含结束的来源(检查__typename价值) :

  • 通过拉取请求 https://github.blog/2013-05-14-closing-issues-via-pull-requests/: PullRequest
  • 通过提交消息 https://github.blog/2013-01-22-closing-issues-via-commit-messages/: Commit
  • 或通过关闭按钮或 Github API :null

以下请求是 3 种关闭类型的示例

通过拉取请求关闭

这个拉取请求 https://github.com/mui-org/material-ui/pull/21107 closed 这个问题 https://github.com/mui-org/material-ui/issues/19641

{
  repository(name: "material-ui", owner: "mui-org") {
    issue(number: 19641) {
      timelineItems(itemTypes: CLOSED_EVENT, last: 1) {
        nodes {
          ... on ClosedEvent {
            createdAt
            closer {
              __typename
            }
          }
        }
      }
    }
  }
}

Output

{
  "data": {
    "repository": {
      "issue": {
        "timelineItems": {
          "nodes": [
            {
              "createdAt": "2020-05-20T09:06:11Z",
              "closer": {
                "__typename": "PullRequest"
              }
            }
          ]
        }
      }
    }
  }
}

通过提交消息关闭

这次提交 https://github.com/rubinius/rubinius/commit/ac420247b365191e1abe62cd8c6ea5847eb417b6 closed 这个问题 https://github.com/rubinius/rubinius/issues/1536

{
  repository(name: "rubinius", owner: "rubinius") {
    issue(number: 1536) {
      timelineItems(itemTypes: CLOSED_EVENT, last: 1) {
        nodes {
          ... on ClosedEvent {
            createdAt
            closer {
              __typename
            }
          }
        }
      }
    }
  }
}

Output

{
  "data": {
    "repository": {
      "issue": {
        "timelineItems": {
          "nodes": [
            {
              "createdAt": "2012-01-30T22:33:11Z",
              "closer": {
                "__typename": "Commit"
              }
            }
          ]
        }
      }
    }
  }
}

通过按钮或 Github API 关闭

这个问题 https://github.com/rubinius/rubinius/issues/3830通过关闭按钮关闭:

{
  repository(name: "rubinius", owner: "rubinius") {
    issue(number: 3830) {
      timelineItems(itemTypes: CLOSED_EVENT, last: 1) {
        nodes {
          ... on ClosedEvent {
            createdAt
            closer {
              __typename
            }
          }
        }
      }
    }
  }
}

Output

{
  "data": {
    "repository": {
      "issue": {
        "timelineItems": {
          "nodes": [
            {
              "createdAt": "2020-02-02T22:31:05Z",
              "closer": null
            }
          ]
        }
      }
    }
  }
}

Github 应用程序使用 Github API 进行调用以关闭问题,performed_via_github_app被设置为非null if you open通过 Github 应用程序生成的 api 调用产生的问题。但performed_via_github_app没有指定问题是通过哪种方式关闭的:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

是否可以通过 GitHub API 查明问题是否已通过拉取请求关闭 的相关文章

随机推荐

  • 你们有 SQL 注入测试“Ammo”吗?

    当阅读有关 SQL 注入和 XSS 的内容时 我想知道你们是否有一个字符串可以用来识别这些漏洞和其他漏洞 可以放入网站数据库中的字符串 用于黑盒检查该字段是否安全 将对一些内部工具进行大型测试 粗略的例子 想知道你们是否知道更多 a 或 1
  • F# 中的“导入”相当于什么

    如何从 F 中的另一个文件导入函数 像你所做地import在Python中 我试过open using 没有任何效果 我看了官方文档 还是不明白如何使用 基本上 我想要这样的东西 Log fs module Log let log prin
  • 在 spring mvc log4j 中为每个日志消息添加字符串前缀

    我希望将我的字符串作为前缀添加到应用程序中的每个日志消息中 我的意思是 我有几个 java 应用程序 我希望其中一个在消息中具有一些前缀 例如 DATE INFO or other sample gt this is my added st
  • 在不同容器中渲染组件并共享状态

    我有一个由 WordPress 预渲染的 HTML 页面和三个 React 组件
  • 理解正则表达式 [\s\S-[<>]]*

    我有这个正则表达式 s S lt gt 你能帮我理解这个表达代表什么吗 据我所知 这意味着由空格和从非空格字符到 的范围组成的字符类 没有多大意义 Thanks 这是一个仅受少数正则表达式引擎 NET JGSoft XML Schema 和
  • 如何在laravel公共文件夹中安装wordpress

    我也点击此链接 但这不是我的解决方案 laravel 和 wordpress 在同一域中 laravel 在子文件夹中 https stackoverflow com questions 29018742 laravel and wordp
  • Gradle 子项目未包含在类路径中

    我们设置了 2 个项目 1 个主项目和 1 个子项目 它们是 Java 项目 它们都在同一个目录下 目录结构如下 dev Project A build gradle settings gradle Project B build grad
  • 如何每小时调用一次函数?另外,我怎样才能循环这个?

    我需要一种简单的方法来每 60 分钟调用一个函数 我怎样才能做到这一点 我正在制作一个 MineCraft bukkit 插件 这就是我所拥有的 package com webs playsoulcraft plazmotech java
  • 识别评论用户并发送通知 Laravel

    我有一个帖子系统 在我的网站上 用户可以发布文章并对每篇文章发表评论 我想发布 当任何用户 不是帖子的作者 评论帖子时 我需要向帖子的作者发送通知 该帖子由 UserName 评论 我这样做 在 CommentController 中 我有
  • 使用 HTTP 和 REGEX 清除 Varnish

    我想使用 HTTP 清除清漆中的元素 这个http调用是从varnish本身后面的后端服务器触发的 因此后端服务器除了HTTP之外没有其他访问权限 我已经使用相应的 ACL 实施了以下清除规则 该规则适用于 curl X PURGE htt
  • 在 git 中管理本地更改我不想提交

    所以我有一些已更改的文件版本 这些都是非常个人化的更改 例如 为 javascript 构建关闭缩小功能 我永远不会提交 但我确实想让它保持开放状态 以便根据其他人的更改进行更新 目前 每次更新工作区时我都必须进行堆栈保存 这变得非常烦人
  • 可启动和跨平台应用程序并使用delphi或Pascal

    是否可以使用 Delphi 或 Pascal 创建可启动 MBR 应用程序 应用程序 我知道我们不能使用 vcl RTL 和其他东西 因为它们依赖于操作系统 但我可以至少使用 Readln 和 writeln 吗 如果是真的的话 我们可以在
  • 如何暂停/恢复视频录制

    我想在录制视频时实现暂停 恢复功能 MediaRecorder 没有任何暂停 恢复方法 本机相机应用程序具有暂停 恢复功能 可以实施吗 请指导我 任何帮助或指导将不胜感激 None
  • Azure Pipeline 使用 YAML 触发 Pipeline

    当使用 YAML 完成另一个管道时尝试触发 Azure 管道 有文档 https github com microsoft azure pipelines yaml blob master design pipeline resources
  • Android ListView 有两个按钮设置可见性问题

    I have Drag Sort Listview https github com bauerca drag sort listview与以下项目 1 文本视图2 两个按钮 ON和OFF 一次只有一个按钮可见 关闭状态的图像 http p
  • 是否可以在自定义组件中使用骆驼组件?

    我最近开始使用 Apache Camel 我们正在考虑创建自定义组件来抽象大量逻辑并简化路由 但其中一些逻辑涉及 http 请求和其他部分 这些部分具有我们想要利用的现有 Camel 组件 是否可以从我们的自定义组件的生产者中调用其他组件
  • 使用ajax调用Struts 2动作,直接向响应写入字符串,不返回字符串

    在 struts2 应用程序中 我调用 Ajax 请求并将字符串直接写入响应 如下所示并返回null在操作的执行方法中 ServeletActionContext getResponse getOutputStream print samp
  • 如何将逻辑运算符应用于Python列表中的所有元素

    我有一个 python 中的布尔值列表 我想对它们进行 与 或 或 或 非 并得到结果 下面的代码可以工作 但不太Pythonic def apply and alist if len alist gt 1 return alist 0 a
  • JSP 技巧让模板制作变得更容易?

    在工作中我的任务是转动一堆HTML文件转化为简单的JSP项目 它实际上都是静态的 没有可编程的服务器端逻辑 我应该提到我对 Java 完全陌生 JSP 文件似乎可以轻松地使用常见的包含和变量 就像PHP 但我想知道一种简单的方法来获得模板继
  • 是否可以通过 GitHub API 查明问题是否已通过拉取请求关闭

    I m using github script https github com marketplace actions github script for GitHub actions which allows you to easily