ds-watch-pr

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Keep one PR moving until it is green and reviewed, with as little noise as possible.
The watcher is
scripts/watch_pr.py
in this skill's folder. Call it by absolute path. It needs
python3
and a logged-in
gh
.
bash
python3 <skill>/scripts/watch_pr.py <pr> [--repo owner/name] [--until ready|green|any] [--interval 30] [--max-minutes 60]
It prints one line per new check failure, finished check run, comment or review, then a final
stop:
line. Exit 0 means the condition is met or the PR merged. Exit 1 means you must act. Exit 2 means bad input.
ready
waits for green checks, a mergeable branch and no change request.
green
waits for checks only.
尽可能在减少打扰的情况下,让一个 PR 持续推进,直到检查通过并完成评审。
watcher
是此 skill 文件夹中的
scripts/watch_pr.py
。请使用绝对路径调用。它需要
python3
和已登录的
gh
。
bash
python3 <skill>/scripts/watch_pr.py <pr> [--repo owner/name] [--until ready|green|any] [--interval 30] [--max-minutes 60]
每次出现新的检查失败、检查任务结束、评论或评审时,它会输出一行,最后再输出一行
stop:
。退出码 0 表示目标条件已满足或 PR 已合并。退出码 1 表示需要采取行动。退出码 2 表示输入无效。
ready
会等待检查全部通过、分支可合并且没有 change request。
green
只等待检查通过。

Steps

步骤

  1. Handle what already exists: failed checks and comments newer than the last push.
  2. Start the watcher. Run it in the harness's background or monitor tool if it has one, so each line wakes you. Otherwise run it as one long foreground command.
  3. On each event, read the source before you change code. Decide if the finding is real.
  4. For a real bug or CI failure: make the smallest fix, run the failing check locally, push, then restart the watcher.
  5. For a false positive or out-of-scope request: reply with a short reason through
    ds-pr-comments
    , resolve the thread and list it as a follow-up.
  6. Tell real test failures apart from infrastructure flakes. Re-run a flake once before you call it a flake.
  7. If the base branch moved or the branch is behind, rebase, push with
    --force-with-lease
    and restart.
  8. Before you call the PR ready,
    git fetch
    and read the PR again. It must not be BEHIND or DIRTY.
  1. 处理已经存在的事项:上次 push 之后新增的失败检查和评论。
  2. 启动 watcher。如果 harness 提供后台任务或监控工具,就通过它运行 watcher,使每一行输出都能触发你处理;否则,将它作为一条长时间运行的前台命令执行。
  3. 每次收到事件时,在修改代码前先阅读相关源码。判断发现的问题是否真实存在。
  4. 对于真实 bug 或 CI 失败:进行最小修复,在本地运行失败的检查,push,然后重启 watcher。
  5. 对于误报或范围外的请求:通过
    ds-pr-comments
    简短说明原因,解决该 thread,并将其列为 follow-up。
  6. 区分真实测试失败与基础设施 flake。在判定为 flake 之前,先重新运行一次。
  7. 如果 base branch 发生移动,或当前 branch 处于落后状态,则执行 rebase,使用
    --force-with-lease
    push,然后重启 watcher。
  8. 在将 PR 标记为 ready 前,执行
    git fetch
    并再次读取 PR。其状态不能是 BEHIND 或 DIRTY。

Stop when

停止条件

  • The watcher exits 0. Report the PR as ready, or merged.
  • Five fix-and-push cycles pass without exit 0. Report what still fails.
  • Another PR makes this one obsolete. Stop and ask before closing it.
  • gh
    reports a rate limit. Check
    gh api rate_limit
    and wait for the reset once. Do not loop.
  • watcher 以退出码 0 退出。报告 PR 已 ready,或已 merged。
  • 经过五轮 fix-and-push 后仍未以退出码 0 结束。报告仍然失败的内容。
  • 另一个 PR 使当前 PR 失去必要性。停止操作,并在关闭之前询问用户。
  • gh
    报告达到速率限制。检查
    gh api rate_limit
    ,并等待一次重置。不要循环重试。

Rules

规则

  • One watcher per PR. Never write your own sleep or polling loop.
  • When an event needs no action, say nothing. No "still waiting" messages.
  • Merge only if the user asked for it. Otherwise report ready.
  • Keep the PR small. Prefer fixes that delete or narrow code.
  • 每个 PR 只能有一个 watcher。绝不要自行编写 sleep 或轮询循环。
  • 事件无需处理时,不要发出任何消息,也不要发送“仍在等待”之类的状态。
  • 仅当用户明确要求时才执行合并;否则报告 PR 已就绪。
  • 保持 PR 小而集中。优先选择能够删除或收窄代码的修复。