MCPcopy Create free account
hub / github.com/github/gh-aw / SetGHHostEnv

Function SetGHHostEnv

pkg/workflow/github_cli.go:235–244  ·  view source on GitHub ↗

SetGHHostEnv sets the GH_HOST environment variable on the command for non-github.com hosts. This is needed for GitHub Enterprise Server (GHES) and Proxima (data residency) instances because commands like `gh repo view`, `gh pr create`, and `gh run view` do not accept a --hostname flag (unlike `gh ap

(cmd *exec.Cmd, host string)

Source from the content-addressed store, hash-verified

233// because commands like `gh repo view`, `gh pr create`, and `gh run view` do not accept a
234// --hostname flag (unlike `gh api` which does).
235func SetGHHostEnv(cmd *exec.Cmd, host string) {
236 if host == "" || host == "github.com" {
237 return
238 }
239 if cmd.Env == nil {
240 cmd.Env = append(os.Environ(), "GH_HOST="+host)
241 } else {
242 cmd.Env = append(cmd.Env, "GH_HOST="+host)
243 }
244}
245
246// ForceGHHostEnv forces GH_HOST=<host> on the command's environment, overriding
247// any GH_HOST already present in the process environment or cmd.Env.

Callers 5

fetchAuditJobLogFunction · 0.92
TestSetGHHostEnvFunction · 0.85
setupGHCommandFunction · 0.85
RunGHWithHostFunction · 0.85
RunGHContextWithHostFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSetGHHostEnvFunction · 0.68