Skip to content

feat: GitHub Enterprise Server and GHE.com - #29

Open
devblac wants to merge 1 commit into
mainfrom
feat/github-enterprise
Open

devblac wants to merge 1 commit into
mainfrom
feat/github-enterprise

Conversation

@devblac

@devblac devblac commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Closes #2.

Approach

#2 asked for an api_base_url replacing https://api.github.com. Since prw now has per-host clients (Bitbucket), GitHub Enterprise is added as another host instead: github.com keeps working, and people with GitHub at work and open source on github.com can watch both.

prw config set github_enterprise_url https://github.acme.com
gh auth login --hostname github.acme.com   # or GH_ENTERPRISE_TOKEN
prw watch https://github.acme.com/team/api/pull/9
  • API base: https://<host>/api/v3 (Enterprise Server) or https://api.<sub>.ghe.com (GHE.com); the URL is validated on config set.
  • Token: github_enterprise_token → GH_ENTERPRISE_TOKEN → GITHUB_ENTERPRISE_TOKEN → gh auth token --hostname <host>. The github.com token is never sent to the Enterprise host.
  • Works in watch/run/wait/checks --logs/list/broadcast/dashboard, auto-watch (--mine / --review-requested search both hosts) and MCP. prw flaky stays github.com-only.
  • One Enterprise instance at a time (enough for the use case in GitHub Enterprise support via configurable API base URL #2; the host abstraction would allow more later).

Test plan

  • go test -race ./..., go vet ./...
  • URL parsing and host normalization (ports, casing, www.), API URL derivation, token precedence, config validation
  • clientFor on an Enterprise URL sends GET /api/v3/repos/team/api/pulls/9 with the Enterprise token (fake server)
  • On a real GitHub Enterprise instance

🤖 Generated with Claude Code

GitHub Enterprise is a third host next to github.com and Bitbucket, rather
than a replacement API base URL, so work and open-source PRs can be watched
together.

- forge: any <host>/owner/repo/pull/N URL parses, with the host kept; hosts
  other than github.com and bitbucket.org are GitHub Enterprise. Links, the
  watch-list host and list labels ("github.acme.com:team/api") follow.
- config: github_enterprise_url and github_enterprise_token; the token falls
  back to GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN and
  `gh auth token --hostname <host>`, never to the github.com token.
- github: EnterpriseAPIURL (<host>/api/v3, or api.<sub>.ghe.com) and
  NewEnterpriseClient.
- clientFor, prw run (client + auto-watch finder), the dashboard source and
  the MCP tools use it; unknown hosts get a hint to set github_enterprise_url.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T03:54:27.991075Z 9339c2e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9339c2e575

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/prw/clients.go
if err != nil {
return nil
}
return watcher.GitHubFinder{Searcher: c, HostName: host}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Parse Enterprise URLs in the search-result decoder

For a configured Enterprise instance, this finder calls github.Client.SearchPullRequests, but that method still decodes each result using github.ParsePRURL (internal/github/client.go:403), whose regex only accepts github.com. Consequently, results with URLs such as https://github.acme.com/team/api/pull/9 are silently skipped, so Enterprise auto-watch never discovers PRs. The new dashboard source uses the same method and likewise displays no Enterprise PRs. Update the search-result decoder to accept Enterprise URLs as well.

Useful? React with 👍 / 👎.

Comment thread cmd/prw/clients.go
Comment on lines +66 to 67
if len(cfg.AutoWatch) > 0 && !bitbucketConfigured(cfg) && cfg.EnterpriseHost() == "" {
return true // auto-watch has nothing else to search

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow Enterprise-only auto-watch with an empty watch list

When only Enterprise credentials are configured and auto-watch is enabled, an empty watch list still makes needsGitHub return true through its final return len(cfg.WatchedPRs) == 0. Thus, after all watched Enterprise PRs close—or when the initial search finds none—prw run exits with errMissingToken in cmd/prw/main.go:435–436, before registering the Enterprise finder. Account for the configured Enterprise auto-watch host in the empty-list fallback so monitoring can start without a github.com token.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub Enterprise support via configurable API base URL

1 participant