Repository navigation
fix(server): apply the selected GitHub account to all network git operations - #11
Merged
Merged
Conversation
…rations Account switching was opt-in per call site, so the paths that mattered most never picked up the project's account: the background fetch that refreshes the branch list / ahead-behind counts, `git pull`, and several `fetch*` variants all ran with no account token and authenticated as whichever account `gh auth switch` last made active machine-wide. That forced a manual `gh auth switch` just to see the right branches. - Centralize network-git auth in `resolveNetworkGitEnv` and route every remote-touching git command through it (status fetch, pull, push, all fetch variants) so account selection can't be silently skipped. - Rewrite the account host's SSH remotes to HTTPS (url.insteadOf, scoped to the process) so the token applies even for `git@host:` remotes. - Surface an unusable selected account (expired/revoked token) in the GitHub account selector instead of silently falling back to the machine default; the per-account reason from `gh auth status` was already parsed but dropped before reaching the UI. Commit authorship is intentionally left on local git config. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Per-project GitHub account switching was opt-in per call site, and the paths that mattered most never opted in. When a project had an account attached, only
pushandghused its token. The background fetch that refreshes the branch list / ahead-behind counts (fetchRemoteForStatus),git pull, and severalfetch*variants ran with no account token and authenticated as whichever accountgh auth switchlast made active machine-wide — forcing a manualgh auth switchjust to see the right branches.Changes
GitVcsDriverCore.ts): newresolveNetworkGitEnv, and every remote-touching git command now routes through it — status fetch,pull,push, and allfetch*variants — so account selection can't be silently skipped by a call site that forgot to opt in.GitHubAccountResolver.ts):gitHubAccountAuthEnvadds a process-scopedurl.https://<host>/.insteadOfforgit@<host>:andssh://git@<host>/, so the account token applies even for SSH remotes. The stored remote URL is untouched.GitHubSourceControlProvider.ts+SidebarV2.tsx): the per-account failure reason fromgh auth statuswas parsed but dropped; it now flows through a new optionalauthErrorfield, and the GitHub account selector warns when the selected account's token is expired/revoked instead of silently falling back to the default.Commit authorship is intentionally left on local git config (
user.name/user.email).Testing
pnpm typecheck— clean (0 errors)GitHubAccountResolver.test.tsandManager.test.tsfor the newGIT_CONFIGpairs.🤖 Generated with Claude Code