Uh oh!
There was an error while loading. Please reload this page.
Add GHES auto-detection to audit and add-wizard commands - #20973
Conversation
- Auto-detect GHES host from git remote when hostname is not provided - audit command: Auto-detects hostname parameter if empty - add-wizard command: Sets GH_HOST environment variable if not set - Uses existing getHostFromOriginRemote() function from pr_command.go - Resolves issue #20933: gh aw audit should auto-detect GHES and set GH_HOST - Applies to add-wizard command as requested in issue comments Fixes#20933
lpcox
commented
Mar 14, 2026
@claude[agent] fix the pr title and summary |
Updated PR title and description to better reflect the changes: "Add GHES auto-detection to audit and add-wizard commands" |
There was a problem hiding this comment.
Pull request overview
Adds automatic GitHub Enterprise Server (GHES) host detection for gh aw audit and gh aw add-wizard by deriving the host from the git origin remote when a hostname isn’t explicitly provided/configured.
Changes:
audit: If no hostname is provided, infer it fromremote.origin.urland include it in subsequentghcalls.add-wizard/ interactive add: IfGH_HOSTis unset, infer it fromremote.origin.urland setGH_HOSTfor subsequentghcalls.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/cli/audit.go | Adds hostname auto-detection from git origin when hostname is empty (including job-specific audit path). |
| pkg/cli/add_interactive_orchestrator.go | Sets GH_HOST env var from git origin for interactive add flows when not already set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| // Auto-detect GHES host from git remote if hostname is not provided | ||
| if hostname == "" { | ||
| hostname = getHostFromOriginRemote() | ||
| if hostname != "github.com" { | ||
| auditLog.Printf("Auto-detected GHES host from git remote: %s", hostname) | ||
| } | ||
| } |
| // Auto-detect GHES host from git remote if hostname is not provided | ||
| if hostname == "" { | ||
| hostname = getHostFromOriginRemote() | ||
| if hostname != "github.com" { | ||
| auditLog.Printf("Auto-detected GHES host from git remote: %s", hostname) | ||
| } | ||
| } |
| // Auto-detect GHES host from git remote if hostname is not provided | ||
| if hostname == "" { | ||
| hostname = getHostFromOriginRemote() | ||
| if hostname != "github.com" { | ||
| auditLog.Printf("Auto-detected GHES host from git remote: %s", hostname) | ||
| } | ||
| } |
| // Auto-detect GHES host from git remote if not already set | ||
| if os.Getenv("GH_HOST") == "" { | ||
| detectedHost := getHostFromOriginRemote() | ||
| if detectedHost != "github.com" { | ||
| addInteractiveLog.Printf("Auto-detected GHES host from git remote: %s", detectedHost) | ||
| os.Setenv("GH_HOST", detectedHost) | ||
| if verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Auto-detected GitHub Enterprise host: "+detectedHost)) | ||
| } | ||
| } | ||
| } |
pelikhan
commented
Mar 14, 2026
@claude merge main, review comments |
Uh oh!
There was an error while loading. Please reload this page.
…expansion - cli.md: note that gh aw audit and add-wizard auto-detect the GHES host from the git remote (from #20973), so GH_HOST is not required manually - github-tools.md: update Safe Outputs Integration section to reflect that write-sink guard policies are now derived for ALL non-GitHub MCP servers (playwright, serena, mcp-scripts, agentic-workflows, web-fetch, custom tools), not only safe-outputs (from #21005) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds automatic GitHub Enterprise Server (GHES) host detection to
gh aw auditandgh aw add-wizardcommands.Changes
GH_HOSTenvironment variable if not already setgetHostFromOriginRemote()function frompr_command.goProblem Solved
Previously, users had to manually prefix commands with
GH_HOST=<ghes-host>when working with GHES repositories:Implementation
auditcommand: Detects hostname from git remote if empty parameteradd-wizardcommand: SetsGH_HOSTenvironment variable for all subsequent gh CLI calls