Skip to content

Fix error message when using GH_ENTERPRISE_TOKEN but host is ambiguous#4019

Merged
mislav merged 3 commits intotrunkfrom
enterprise-env
Jul 27, 2021
Merged

Fix error message when using GH_ENTERPRISE_TOKEN but host is ambiguous#4019
mislav merged 3 commits intotrunkfrom
enterprise-env

Conversation

@mislav
Copy link
Contributor

@mislav mislav commented Jul 20, 2021

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.

Fixes #3522

mislav added 2 commits July 20, 2021 14:11
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.
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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's up with example.com here?

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@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.

@mislav mislav requested a review from vilmibm July 26, 2021 17:00
@mislav mislav merged commit fdad37e into trunk Jul 27, 2021
@mislav mislav deleted the enterprise-env branch July 27, 2021 13:29
Copy link

@adamsofea1111 adamsofea1111 left a comment

Choose a reason for hiding this comment

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

pkg/cmd/root/help_topic.go

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.

Confusing error when using GH_ENTERPRISE_TOKEN if gh auth login was never used.

4 participants