mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-17 18:32:19 +02:00
fix(next-version): only trust ls-remote when origin is actually configured
Without the guard, git DWIMs the literal 'origin' as an ssh host/path; on hosts whose transport launders exit codes the probe 'succeeds' with zero branches and the allocator silently sees an empty queue — the exact duplicate-allocation failure (#2545) fetchGitClaimed exists to prevent. git remote get-url origin gates the probe; absence falls through to the existing local-refs path with its staleness warning. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
8fd2783175
commit
8de9f39c82
+20
-6
@@ -499,12 +499,26 @@ function fetchGitClaimed(
|
|||||||
// claim set and pushed the allocation further than the real queue.
|
// claim set and pushed the allocation further than the real queue.
|
||||||
// GIT_TERMINAL_PROMPT=0 + a 5s timeout keep a dead/credential-prompting
|
// GIT_TERMINAL_PROMPT=0 + a 5s timeout keep a dead/credential-prompting
|
||||||
// remote from hanging the allocator.
|
// remote from hanging the allocator.
|
||||||
const lsRemote = spawnSync("git", ["ls-remote", "--heads", "origin"], {
|
// Guard: only consult ls-remote when a remote named `origin` is actually
|
||||||
encoding: "utf8",
|
// CONFIGURED. Without the guard, git DWIMs the literal `origin` as an
|
||||||
timeout: 5000,
|
// ssh host/path — and on hosts whose ssh launders exit codes (observed:
|
||||||
env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
|
// Vercel sandboxes' ssh exits 0 on "Could not resolve hostname"), the
|
||||||
});
|
// probe "succeeds" with zero branches and the allocator silently sees an
|
||||||
const lsOk = lsRemote.status === 0 && !lsRemote.error;
|
// empty queue: the exact duplicate-allocation failure (#2545) this
|
||||||
|
// function exists to prevent.
|
||||||
|
const originConfigured =
|
||||||
|
spawnSync("git", ["remote", "get-url", "origin"], {
|
||||||
|
encoding: "utf8",
|
||||||
|
timeout: 5000,
|
||||||
|
}).status === 0;
|
||||||
|
const lsRemote = originConfigured
|
||||||
|
? spawnSync("git", ["ls-remote", "--heads", "origin"], {
|
||||||
|
encoding: "utf8",
|
||||||
|
timeout: 5000,
|
||||||
|
env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
|
||||||
|
})
|
||||||
|
: null;
|
||||||
|
const lsOk = lsRemote !== null && lsRemote.status === 0 && !lsRemote.error;
|
||||||
|
|
||||||
// Each candidate carries the LIVE tip sha when it came from ls-remote, so
|
// Each candidate carries the LIVE tip sha when it came from ls-remote, so
|
||||||
// the VERSION read prefers the fresh commit (present locally after any
|
// the VERSION read prefers the fresh commit (present locally after any
|
||||||
|
|||||||
Reference in New Issue
Block a user