Repository navigation
fix: only call gh for GitHub hosts - #93
Merged
Merged
Conversation
The host passed to `gh api graphql --hostname` comes from the remote URL, which can be any git server. gh sends GH_ENTERPRISE_TOKEN (and GITHUB_ENTERPRISE_TOKEN) to every host other than github.com, so a sync in a repository whose remote is not on GitHub sent that token to the remote's host. gh is now only called for github.com, *.ghe.com, the host in GH_HOST and hosts with credentials stored by `gh auth login`. Any other host is a failed lookup: the branches that depend on it are kept. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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
For a gone branch whose commits are not in the default branch, gh-sync runs
gh api graphql --hostname <host>, with the host taken from the remote URL. The remote can be any git server, and gh appliesGH_ENTERPRISE_TOKEN/GITHUB_ENTERPRISE_TOKENto every host other than github.com. So with that variable set, runninggh syncin a repository whose remote is not on GitHub sent the token tohttps://<host>/api/graphql.Fix
checkGhHostruns beforegh apiand only lets through:*.ghe.comGH_HOSTgh auth login, checked withgh auth token --hostname <host>run without the token environment variables (the printed token is discarded)Any other host is a failed lookup, as before for an unauthenticated gh: a warning, and the branches that depend on the lookup are kept. The answer is cached per host for the sync.
Behavior change
A GitHub Enterprise Server host used only through
GH_ENTERPRISE_TOKEN, with neithergh auth loginnorGH_HOST, no longer gets squash-merge detection. SettingGH_HOSTrestores it. Both READMEs say so.Testing
mise run testandmise run lintpass.GH_ENTERPRISE_TOKENset.ghthat records its calls andGH_ENTERPRISE_TOKENset: nogh apicall for an unknown host;gh apiis called withGH_HOSTset or whengh auth tokensucceeds. The stored-credentials path with a realghlogin is not covered by an automated test.🤖 Generated with Claude Code