Fix error message when using GH_ENTERPRISE_TOKEN but host is ambiguous#4019
Fix error message when using GH_ENTERPRISE_TOKEN but host is ambiguous#4019
Conversation
Before:
$ GH_ENTERPRISE_TOKEN="..." gh pr create
could not find hosts config: not found
Now:
$ GH_ENTERPRISE_TOKEN="..." gh pr create
set the GH_HOST environment variable to specify which GitHub host to use
Also amends `gh help environment` documentation to suggest the use of
GH_HOST when scripting operations with GitHub Enterprise repositories.
pkg/cmd/factory/remote_resolver.go
Outdated
| remotesError = errors.New("none of the git remotes configured for this repository point to a known GitHub host. To tell gh about a new GitHub host, please use `gh auth login`") | ||
| if config.IsHostEnv(src) { | ||
| return nil, fmt.Errorf("none of the git remotes configured for this repository correspond to the %s environment variable. Try adding a matching remote or unsetting the variable.", src) | ||
| } else if v, src, _ := cfg.GetWithSource("example.com", "oauth_token"); v != "" && config.IsEnterpriseEnv(src) { |
There was a problem hiding this comment.
what's up with example.com here?
There was a problem hiding this comment.
hello we have to understand the server and the owner and about web browsing and about the so-called linking and capture system and their existence needs change and new enhancement to the grasp It's fast and works without hesitation. I don't mind about the goal in the development system to share with the community
There was a problem hiding this comment.
@vilmibm Good spot! I'm using GetWithSource to check whether an enterprise token was set via the environment. Env variables like GH_ENTERPRISE_TOKEN will only get consulted if the host argument is non-blank and is a non-github.com host. Since I do not know the actual hostname in this block and since it doesn't matter, I've used an arbitrary hostname. I should probably make a code comment for it.
Before:
Now:
Also amends
gh help environmentdocumentation to suggest the use of GH_HOST when scripting operations with GitHub Enterprise repositories.Fixes #3522