feat(github): support GitHub Enterprise Server hosts in pull requests (#6729)

gh api does not take the host from the remote as gh pr does, so requests for an Enterprise repository went to github.com. GhApiRequest now carries an optional host passed as gh api --hostname (validated as host[:port]); the GitHub tool window sends the connected repository's host, availability reads the login on that host, and remotes on the host gh resolved count as GitHub remotes. Commit checks in the Git log keep github.com.

Fixes #6717

Co-authored-by: wildcatDownstairs <[email protected]>
Цей коміт міститься в:
LU XIANGRUIтаwildcatDownstairs authored and GitHub committed 2026-11-28 21:00:14 +08:00
1 джерело 16e5cb5763
коміт 2ea7d6c41b
13 files changed
+223 -40

No files matched your search

+3 -3
Переглянути файл
@@ -4,7 +4,7 @@ import { graphql, repoVariables } from "../api/client";
import type { GHCommitStatusContextState, GHRepositoryCoordinates } from "../api/types";
import { githubRemotes } from "./repository";
type Target = GHRepositoryCoordinates & { root: string };
type Target = GHRepositoryCoordinates & { root: string; host: string };
export interface LogCommitCheck {
state: GHCommitStatusContextState;
target: Target;
@@ -20,7 +20,7 @@ async function targets(root: string): Promise<Target[]> {
if (previous && previous.expires > Date.now()) return previous.targets;
const remotes = githubRemotes(await call(commands.vcsRemotes(root)).catch(() => []), root);
remotes.sort((a, b) => Number(b.remote === "origin") - Number(a.remote === "origin"));
const resolved = remotes.map(({ owner, name }) => ({ owner, name, root }));
const resolved = remotes.map(({ owner, name, host }) => ({ owner, name, root, host: host ?? "github.com" }));
if (remoteCache.size >= 128) remoteCache.delete(remoteCache.keys().next().value!);
remoteCache.set(root, { targets: resolved, expires: Date.now() + REMOTE_TTL });
return resolved;
@@ -37,7 +37,7 @@ async function queryBatch(target: Target, revisions: string[]) {
const variables = Object.fromEntries(revisions.map((oid, i) => [`oid${i}`, oid]));
const data = await graphql<{
repository: Record<string, { statusCheckRollup: { state: GHCommitStatusContextState } | null } | null> | null;
}>(doc, { ...repoVariables(target), ...variables }, target.root);
}>(doc, { ...repoVariables(target), ...variables }, target.root, target.host);
return revisions.map((_, i) => data.repository?.[`c${i}`]?.statusCheckRollup?.state ?? null);
}