Newshot

使用 GitHub CLI 等待拉取请求事件

AI summary

GitHub CLI 现已支持 GitHub Event Streams。从 gh v2.105.0 起,你和你的 agent 只需一条命令即可等待拉取请求发生变化,无需在循环中轮询:运行 gh event listen 并传入拉取请求 URL 和你关注的事件(例如已提交的评审),它会创建订阅、打开事件流,并将每个事件打印为一行 JSON。默认在首个事件后退出,可用 --count 等待多个事件、--follow 持续监听、--timeout 停止等待,并用 --jq 或 --template 只提取所需字段。

Translation(model translation, not the source's own text)

GitHub CLI 现已支持 GitHub Event Streams。借助 gh v2.105.0,你和你的 agent 只需一条命令即可等待拉取请求发生变化,而不必在循环中轮询。

用拉取请求 URL 和你关心的事件(例如已提交的评审)运行 gh event listen。它会创建订阅、打开流,并将每个事件作为一行 JSON 打印出来。

  • 默认情况下,它在第一个事件后退出,因此可以方便地嵌入脚本和 agent 循环。
  • 使用 --count 等待多个事件,使用 --follow 持续监听,使用 --timeout 停止等待。
  • 使用 --jq 或 --template 只提取你需要的字段。

你可以等待已提交的评审、拉取请求状态与 head 变更、合并冲突以及已完成的检查套件。要直接管理订阅,请使用 gh event subscription create、list、view 和 delete。

agent 会自行发现这些新命令:gh pr create、gh pr view、gh run view、gh run watch 和 gh api 现在会建议使用 gh event listen,而不是轮询。

可用性

gh event 命令处于预览阶段,可能会发生变化。它们需要访问 Event Streams,而该功能在 GitHub.com 上处于预览阶段。要获取访问权限,请报名加入 Event Streams 等待名单。

要开始使用,请升级到 gh v2.105.0 或更高版本。详情请参阅 gh event 手册和 Event Streams 文档,或运行 gh event --help。

欢迎在 GitHub Community 讨论中分享你的反馈。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by GitHub Changelog
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗