Skip to content

feat(cli): also honor GH_TOKEN, preferring it over GITHUB_TOKEN#488

Merged
Xoshbin merged 1 commit into
Xoshbin:mainfrom
dose-dot-dev:feat/cli-gh-token-fallback
Jul 10, 2026
Merged

feat(cli): also honor GH_TOKEN, preferring it over GITHUB_TOKEN#488
Xoshbin merged 1 commit into
Xoshbin:mainfrom
dose-dot-dev:feat/cli-gh-token-fallback

Conversation

@dose-dot-dev

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #479: the review there suggested also accepting GH_TOKEN, and I pushed that change to the PR branch — but a few hours after it had already been squash-merged, so it never landed. This PR carries that commit.

  • GH_TOKEN is accepted alongside GITHUB_TOKEN and takes precedence, matching the gh CLI's documented ordering. The ordering is deliberate: in GitHub Actions GITHUB_TOKEN is the ambient workflow-injected token, while GH_TOKEN is only ever set on purpose — the explicit variable should win.
  • Tests cover the fallback and precedence, and clear both variables in beforeEach so an ambient GH_TOKEN on a contributor's machine can't leak into the GITHUB_TOKEN-only cases.

Testing

  • Auth suite 10/10; tsc -p tsconfig.cli.json --noEmit clean; Prettier clean.

🤖 Generated with Claude Code

Review follow-up: accept GH_TOKEN as well, with GH_TOKEN taking
precedence — the gh CLI's documented ordering. GITHUB_TOKEN is ambient
in GitHub Actions while GH_TOKEN is only ever set deliberately, so the
explicit variable wins. Tests clear both variables up front so an
ambient token on a contributor's machine cannot leak into the
single-variable cases, and cover fallback and precedence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for the GH_TOKEN environment variable in the CLI authentication flow, prioritizing it over GITHUB_TOKEN to align with the behavior of the GitHub CLI. The changes update the token retrieval logic to check both variables, log the active source, and expand the test suite to verify precedence and environment isolation. There are no review comments, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Xoshbin Xoshbin merged commit e442e3d into Xoshbin:main Jul 10, 2026
1 check passed
@Xoshbin

Xoshbin commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Thank you 🙏.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants