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

Function GetGitHubHost

pkg/parser/github.go:28–41  ·  view source on GitHub ↗

GetGitHubHost returns the GitHub host URL from environment variables. Environment variables are checked in priority order for GitHub Enterprise support: 1. GITHUB_SERVER_URL - GitHub Actions standard (e.g., https://MYORG.ghe.com) 2. GITHUB_ENTERPRISE_HOST - GitHub Enterprise standard (e.g., MYORG.gh

()

Source from the content-addressed store, hash-verified

26//
27// The function normalizes the URL by adding https:// if missing and removing trailing slashes.
28func GetGitHubHost() string {
29 envVars := []string{"GITHUB_SERVER_URL", "GITHUB_ENTERPRISE_HOST", "GITHUB_HOST", "GH_HOST"}
30
31 for _, envVar := range envVars {
32 if value := os.Getenv(envVar); value != "" { //nolint:osgetenvlibrary
33 githubLog.Printf("Resolved GitHub host from %s: %s", envVar, value)
34 return stringutil.NormalizeGitHubHostURL(value)
35 }
36 }
37
38 defaultHost := string(constants.PublicGitHubHost)
39 githubLog.Printf("No GitHub host environment variable set, using default: %s", defaultHost)
40 return defaultHost
41}
42
43// GetGitHubHostForRepo returns the GitHub host URL for a specific repository.
44// Repositories under the github, githubnext, and microsoft organizations are

Callers 2

getGitHubHostFunction · 0.92
GetGitHubHostForRepoFunction · 0.85

Calls 3

NormalizeGitHubHostURLFunction · 0.92
GetenvMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected