link doesn't recognize a branch's existing merged/closed PR, tries to create a duplicate
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 66/100
Línea de trabajo
Comienza en el punto de entrada gh stack link y sigue la búsqueda de PR existentes antes de que se llame a createPullRequest. Reproduce el problema con ramas fusionadas y cerradas, y compáralo después con gh pr list --head <branch> --state all. Se considera terminado cuando se reconocen los PR existentes en cualquier estado y no se intenta crear ninguno duplicado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Build a stack
main <- a <- b <- c <- d <- eviagh stack link. - Merge
aandb. Closecwithout merging (its content landed elsewhere, or it was abandoned). - Later, run
gh stack linkagain with the full historical branch list (e.g. to fixd's base aftercclosed):
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).
- Lenguaje dominante
- Go
- Estrellas
- 1.5k
- Forks
- 73
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 7
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/gh-stack
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
-
feature request topic: cli - general
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
feature request topic: auto-merge
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
bug topic: docs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
Todos los issues de github/gh-stack
Issues similares
-
area/dev-productivity area/disaster-recovery area/ipcei kind/enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
kind/bug status/0-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
🤔 refinement needed
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
equinor/radix-operator#1979 ·