fix(github): fail closed when the SSH git provider is gone

getCurrentHeadOid and probeTrackedUpstreamBranches only routed through the
SSH provider when one was registered. With connectionId set but the provider
unregistered (dropped connection, not yet reattached) they fell through to
client-side git with cwd pointing at the remote repoPath — on a machine with
a same-named local path that silently answers for the wrong repository.

getCurrentHeadOid feeds shouldHideMergedImplicitPR, so a wrong OID changes
which PR the UI attributes to a worktree.

Both now take their existing unknown path (null / probeFailed) instead,
matching repo-default-branch.ts. Local and WSL routing is unchanged.
This commit is contained in:
Brennan Benson
2026-08-16 18:50:40 -07:00
parent 886dec1d2a
commit dfe64856f6
2 changed files with 227 additions and 2 deletions
+10 -2
View File
@@ -2315,8 +2315,12 @@ async function getCurrentHeadOid(
connectionId?: string | null,
localGitOptions: { wslDistro?: string } = {}
): Promise<string | null> {
const provider = connectionId ? getSshGitProvider(connectionId) : null
if (connectionId && !provider) {
// Why: repoPath is remote — a dropped SSH provider must answer "unknown", never run client git against a same-named local path.
return null
}
try {
const provider = connectionId ? getSshGitProvider(connectionId) : null
const result = provider
? await provider.exec(['rev-parse', 'HEAD'], repoPath)
: await gitExecFileAsync(['rev-parse', 'HEAD'], {
@@ -2814,8 +2818,12 @@ async function probeTrackedUpstreamBranches(
upstreamsByBranchName: Map<string, TrackedUpstreamBranch | null>
}> {
const args = ['for-each-ref', '--format=%(refname)%00%(upstream)', 'refs/heads']
const provider = connectionId ? getSshGitProvider(connectionId) : null
if (connectionId && !provider) {
// Why: repoPath is remote — a dropped SSH provider must fail the probe, never enumerate a same-named local repo's refs.
return { probeFailed: true, upstreamsByBranchName: new Map() }
}
try {
const provider = connectionId ? getSshGitProvider(connectionId) : null
const result = provider
? await provider.exec(args, repoPath)
: await gitExecFileAsync(args, {