cli / cli/cli

gh pr merge --squash --delete-branch: dependent PR closed instead of auto-retargeted to merged PR's base

オープン
#14,223 コメント 6 件 リアクション 1 件 担当者 0 名 GitHub で見る
blocked bug gh-pr platform priority-2
主要言語
Go
スター
46.3k
フォーク
9k
平均マージ
2日 6時間
マージ済み PR(30日)
97

説明

### What happened

A stacked-PR setup: PR #8 (`feat/fix` → base `feat/base`), where `feat/base`
was the head of open PR #7 (`feat/base` → `main`). The stack was assembled
with `gh stack init --adopt` — PR #7 predated the stack and was adopted as
the trunk when the descendant PR was created via `gh stack submit`. Both were
otherwise ordinary PRs with an ordinary base relationship.

I then ran: `gh pr merge 7 --squash --delete-branch`

Per the docs, deleting a merged PR's head branch should retarget open PRs
based on it to the merged PR's base branch. Instead, PR #8 was **closed**.

Timeline evidence (`gh api repos/OWNER/REPO/issues/8/timeline`):

- 19:56:28Z — PR #7 merged (squash)
- 19:56:29Z — `base_ref_deleted` event on PR #8
- 19:56:30Z — `closed` event on PR #8 (no retarget attempted)

### Recovery was a dead end

- `gh pr edit 8 --base main` on the closed PR: "Cannot change the base branch
of a closed pull request."
- `gh pr reopen 8`: refused while the base branch was deleted (expected), but
**also** refused after restoring the base branch, because the head branch
had been rebased/pushed while the PR was closed. Catch-22: the PR had to be
abandoned and recreated as a new PR, losing its identity.

### Questions

1. Is auto-retarget on branch deletion only wired to the web UI's post-merge
"delete branch" flow, and not to a raw ref deletion via the REST API
(which is what `--delete-branch` performs)?
2. If so, should `gh pr merge --delete-branch` warn when open PRs are based
on the branch being deleted?

(If this is platform-side rather than CLI-side, happy to have it routed.)

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

`gh pr merge --squash --delete-branch` のエントリーポイントから開始し、REST API による ref の削除を追跡して、文書化されている retarget の動作および PR のタイムラインイベントと比較します。CLI と GitHub プラットフォームのどちらにこの動作が属するのかを明らかにし、そのうえでフローを修正するか、依存するオープンな PR に対する警告を追加すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
git, github, go
領域
api, cli
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。