`gh stack` resolves the API repository from the `origin` remote, ignoring `--remote`, `gh repo set-default`, and its own state file — silently operating on the wrong repository in multi-remote clones
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
調査の方向性
まず、gh stack init と gh stack submit のエントリーポイントから、--remote、GH_REPO、gh-resolved、および .git/gh-stack の repository フィールドを含むリポジトリ解決の流れを追跡します。選択されたリポジトリを push remote と比較し、インタラクティブフローと --auto フローが意図したリポジトリを対象にするか、解決があいまいな場合に明示的に失敗することを確認します。
索引モデルが issue の本文から書いたものです。
説明
Summary
In a clone with multiple remotes, every gh stack PR/stack API operation is bound to the repository of the origin remote, regardless of:
- the
--remoteflag (which only changes the push target), gh repo set-default/remote.<name>.gh-resolved(the standard gh CLI repo resolution),- the
repositoryfield in.git/gh-stack(editing it has no effect on subsequent runs).
If origin points at a different repository than the one your branches and PRs live in — the completely standard fork workflow where origin is upstream and you push to your fork — gh stack submit pushes to the right remote but then tries to create PRs and stacks on the wrong repository. In --auto / non-interactive mode this happens silently: there is no "Multiple remotes found" prompt (the interactive path in #219 at least shows one).
In my case the only reason no PRs were actually opened against the upstream project is that my branches don't exist there, so every createPullRequest failed. If upstream had happened to contain same-named branches, gh stack submit --auto would have opened a pile of PRs against a repository I never pointed it at. For agent/scripted use this is a dangerous default.
Environment
- gh version 2.96.0
- gh-stack v0.1.0
- Clone with 7 remotes;
origin=github.com/argoproj/argo-workflows(upstream),joibel=github.com/Joibel/argo-workflows(fork, where all stack branches and 8 open PRs live) gh repo set-default Joibel/argo-workflowsis set (remote.joibel.gh-resolved = base)
Steps to reproduce
- Clone a repo with
originpointing at upstream and a second remote pointing at your fork. - Create branches with open PRs on the fork (head and base both on the fork).
gh stack init --base <trunk> <branch1> ... <branchN>— adopts the branches fine, but records"repository": "github.com:<origin-owner>/<repo>"in.git/gh-stack.gh stack submit --remote <fork-remote> --auto
Observed
-
Push goes to the fork remote correctly ("Pushing to joibel... ✓ Pushed and synced 8 branches").
-
All PR operations target the
originrepository: existing fork PRs are not detected, and the extension attemptscreatePullRequestagainst upstream, failing with:⚠ failed to create PR for <branch>: creating PR: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between <base> and <branch>, Head ref must be a branch, Base ref must be a branch (createPullRequest)(Same error signature as #219, different root cause — here the refs genuinely don't exist because it's querying the wrong repository.)
-
The interactive TUI confirms it: the header shows
Repo: argoproj/argo-workflowseven when invoked with--remote joibel. -
None of the following change the target repository:
--remote,gh repo set-default, editing therepositoryfield in.git/gh-stack.
Workaround
GH_REPO=<fork-owner>/<repo> gh stack submit --remote <fork-remote> --auto works perfectly — existing PRs are detected ("PR #NN for is up to date") and the stack is created.
Expected
- Repo resolution should follow the standard gh CLI rules (
GH_REPO, thengh-resolved/gh repo set-default, then remote heuristics), or at minimum follow the remote selected with--remote, since a stack's branches and PRs must by definition (#46) live in the repository the branches are pushed to. - If resolution is ambiguous in non-interactive mode, fail with an explicit "multiple remotes, specify GH_REPO or --remote" error rather than silently picking
origin. gh stack initshould surface/validate which repository it bound the stack to.
Related
- #219 — same GraphQL error signature via a different resolution failure; its interactive run at least got a "Multiple remotes found" prompt, which
--autoskips. - #45, #337 — same code area (deriving the API repo from remote URLs) tripping on SSH aliases / hostname remaps.
- #46 — cross-fork stacks; confirms head+base must be one repository, which makes binding to
origindoubly wrong when pushes go elsewhere.
- 主要言語
- Go
- スター
- 1.5k
- フォーク
- 73
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 7
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/gh-stack のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
feature request topic: cli - general
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
feature request topic: auto-merge
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
bug topic: docs
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
github/gh-stack の issue をすべて見る
似ている issue
-
area/dev-productivity area/disaster-recovery area/ipcei kind/enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
kind/bug status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
🤔 refinement needed
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
equinor/radix-operator#1979 ·