Add GHES auto-detection to audit and add-wizard commands#20973
Merged
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
Claude created this pull request from a session on behalf of
lpcox
March 14, 2026 18:55
View session
Collaborator
|
@claude[agent] fix the pr title and summary |
Contributor
Author
Updated PR title and description to better reflect the changes: "Add GHES auto-detection to audit and add-wizard commands" |
Contributor
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.
Comment on lines
+136
to
+142
| // 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) | ||
| } | ||
| } |
Comment on lines
+444
to
+450
| // 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) | ||
| } | ||
| } |
Comment on lines
+136
to
+142
| // 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) | ||
| } | ||
| } |
Comment on lines
+60
to
+70
| // 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)) | ||
| } | ||
| } | ||
| } |
Contributor
|
@claude merge main, review comments |
github-actions bot
added a commit
that referenced
this pull request
Mar 15, 2026
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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