Skip to content

Commit

Permalink
Merge pull request #17 from cli/gh-host
Browse files Browse the repository at this point in the history
Respect GH_HOST unless `--github-host` was given
  • Loading branch information
mislav committed Jun 6, 2023
2 parents 6d0d8df + d04aceb commit cf30885
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion webhook/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cf30885

Please sign in to comment.