Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

link doesn't recognize a branch's existing merged/closed PR, tries to create a duplicate

未关闭
#373 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
66/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
github, go
领域
api, cli

调研方向

gh stack link 入口开始,跟踪在调用 createPullRequest 之前对现有 PR 的查找流程。使用已合并和已关闭的分支进行复现,然后与 gh pr list --head <branch> --state all 进行比较。完成标准是能够识别任何状态的现有 PR,并且不会尝试重复创建。

由索引模型根据 Issue 内容生成。

描述

bug topic: cli - link

Summary

gh stack link looks up an existing PR for each branch argument, but the lookup appears scoped to open PRs only. For a branch whose PR already merged or was closed (unmerged), link reports no PR found and attempts to create a new one — contradicting the documented additive-only design ("existing PRs are never removed").

Repro

  1. Build a stack main <- a <- b <- c <- d <- e via gh stack link.
  2. Merge a and b. Close c without merging (its content landed elsewhere, or it was abandoned).
  3. Later, run gh stack link again with the full historical branch list (e.g. to fix d's base after c closed):
    gh stack link a b c d e --base main

Actual

Checking existing stacks...
Pushing N branches to origin...
Looking up PRs for 5 branches...
Found PR #.. for branch d
Found PR #.. for branch e
Creating 3 PRs...
✗ failed to create PR for branch a: creating PR: GraphQL: was submitted too quickly, Head sha can't be blank, Base sha can't be blank, No commits between main and a, Head ref must be a branch (createPullRequest)

Only the still-open branches (d, e) were recognized as "Found PR". The merged branch a (whose content is already in main, hence "No commits between main and a") and the closed branch c were both treated as PR-less and queued for creation.

In my case the create call failed immediately on the first attempt (an already-merged branch has no diff vs. its base, so createPullRequest rejects it), so no duplicate PR was actually created — I confirmed this via gh pr list --head <branch> --state all for each affected branch afterward. But this looks like it depends on the specific branch/repo state; a branch that still has some diff against the base (e.g. a closed-but-unmerged PR whose branch wasn't cleaned up) would likely succeed in creating a genuine duplicate PR.

Expected

link's PR lookup should match a branch's PR regardless of state (open, closed, or merged) before deciding whether to create a new one, consistent with the "existing PRs are never removed" behavior documented for this command.

Environment

gh-stack version 0.0.8, installed via gh extension install github/gh-stack.

Related: #372 (same investigation session, different symptom of the same overall stack-mutation scenario — see also the atomicity issue I'm filing separately).

主要语言
Go
星标
1.5k
派生
73
平均合并
1 天 8 小时
30 天内合并 PR
7

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/gh-stack 的其他 Issue

查看 github/gh-stack 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。