From d04aceba4a709ce82c224e06b3b1ba6dc02d1be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 6 Jun 2023 12:50:09 +0200 Subject: [PATCH] Respect GH_HOST unless `--github-host` was given --- webhook/forward.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webhook/forward.go b/webhook/forward.go index b64d527..f313903 100644 --- a/webhook/forward.go +++ b/webhook/forward.go @@ -36,11 +36,15 @@ func NewCmdForward() *cobra.Command { $ gh webhook forward --events=issues --repo=monalisa/smile --url="http://localhost:9999/webhooks" $ gh webhook forward --events=issues --org=github --url="http://localhost:9999/webhooks" `), - RunE: func(*cobra.Command, []string) error { + RunE: func(c *cobra.Command, _ []string) error { if targetRepo == "" && targetOrg == "" { return errors.New("`--repo` or `--org` flag required") } + if envHost := os.Getenv("GH_HOST"); envHost != "" && !c.Flags().Changed("github-host") { + githubHost = envHost + } + authToken, err := authTokenForHost(githubHost) if err != nil { return fmt.Errorf("fatal: error fetching gh token: %w", err)