feat: add --account flag and GH_ACCOUNT env var for per-command account selection#12853
Open
tmehlinger wants to merge 10 commits intocli:trunkfrom
Open
feat: add --account flag and GH_ACCOUNT env var for per-command account selection#12853tmehlinger wants to merge 10 commits intocli:trunkfrom
tmehlinger wants to merge 10 commits intocli:trunkfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When accountOverride is set, ActiveUser returns the overridden user for the matching host, and ActiveToken bypasses the global oauth_token lookup to fetch the per-user token directly via TokenForUser. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Authentication() was creating a new AuthConfig struct on every call, so the account override set in PersistentPreRunE was lost when the HTTP client resolved its token via a separate Authentication() call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Store parsed user/host fields instead of raw string, eliminating redundant ParseAccount() calls in ActiveToken/ActiveUser/DefaultHost - Fix critical bug: ActiveToken() no longer silently falls through to the wrong account when the override account's token lookup fails - Use slices.Contains for account validation in applyAccountOverride - Add end-to-end token assertions to integration tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change SetAccountOverride(account string) to SetAccountOverride(user, host string) to eliminate redundant ParseAccount call and silent error swallowing - Replace map allocation in isAuthMutationCommand with slices.Contains - Use strings.Builder in accountNotFoundError instead of repeated concatenation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for your pull request! Unfortunately, it doesn't meet the minimum requirements for review:
Please update your PR to address the above. Requirements:
This PR will be automatically closed in 7 days if these requirements are not met. |
Author
Member
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.
Summary
--account user@hostpersistent flag andGH_ACCOUNTenvironment variable that lets users specify which authenticated account to use per-command, eliminating the need to globally switch accounts withgh auth switchGH_TOKENprecedence with a warningCloses #326
Test plan
ParseAccountparser (7 cases)ActiveToken,ActiveUser,DefaultHostoverride behavior (4 cases)applyAccountOverride(8 cases covering flag, env var, precedence, errors, GH_TOKEN, auth mutation guard, no-op)go test ./...passes--account user@hostagainst real repos🤖 Generated with Claude Code