From 574742167ad57497245560ebb373c22d47ab03b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 12:51:01 +0000 Subject: [PATCH 1/2] Initial plan From a9c458d82a6f2146759c1a1ed72d70da5835a942 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 13:03:22 +0000 Subject: [PATCH 2/2] Fix enterprise remote auth binding Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/common/remote.ts | 14 +++++++++++++- src/test/common/remote.test.ts | 23 ++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/common/remote.ts b/src/common/remote.ts index c5283ca606..e32ec56e90 100644 --- a/src/common/remote.ts +++ b/src/common/remote.ts @@ -177,7 +177,19 @@ export async function parseRepositoryRemotesAsync(repository: Repository): Promi export class GitHubRemote extends Remote { static remoteAsGitHub(remote: Remote, githubServerType: GitHubServerType): GitHubRemote { - return new GitHubRemote(remote.remoteName, remote.url, remote.gitProtocol, githubServerType); + const githubRemote = new GitHubRemote(remote.remoteName, remote.url, remote.gitProtocol, githubServerType); + Logger.debug(`Remote "${remote.remoteName}" at ${remote.host} was classified as ${GitHubServerType[githubServerType]} and uses ${githubRemote.authProviderId} authentication.`, 'Remote'); + return githubRemote; + } + + public override get authProviderId(): AuthProvider { + if (this.githubServerType === GitHubServerType.Enterprise) { + return AuthProvider.githubEnterprise; + } + if (this.githubServerType === GitHubServerType.GitHubDotCom) { + return AuthProvider.github; + } + return super.authProviderId; } constructor( diff --git a/src/test/common/remote.test.ts b/src/test/common/remote.test.ts index 9e8e3976a4..bafbfef17f 100644 --- a/src/test/common/remote.test.ts +++ b/src/test/common/remote.test.ts @@ -4,9 +4,30 @@ *--------------------------------------------------------------------------------------------*/ import { default as assert } from 'assert'; -import { parseRepositoryRemotesAsync } from '../../common/remote'; +import { AuthProvider, GitHubServerType } from '../../common/authentication'; +import { GitHubRemote, parseRemote, parseRepositoryRemotesAsync } from '../../common/remote'; import { MockRepository } from '../mocks/mockRepository'; +describe('GitHubRemote', () => { + it('uses GitHub Enterprise authentication for an enterprise server', () => { + const remote = parseRemote('origin', 'https://tenant.ghe.com/owner/repo.git'); + assert.ok(remote); + + const githubRemote = GitHubRemote.remoteAsGitHub(remote, GitHubServerType.Enterprise); + + assert.strictEqual(githubRemote.authProviderId, AuthProvider.githubEnterprise); + }); + + it('uses GitHub authentication for GitHub.com', () => { + const remote = parseRemote('origin', 'https://github.com/owner/repo.git'); + assert.ok(remote); + + const githubRemote = GitHubRemote.remoteAsGitHub(remote, GitHubServerType.GitHubDotCom); + + assert.strictEqual(githubRemote.authProviderId, AuthProvider.github); + }); +}); + describe('parseRepositoryRemotesAsync', () => { it('resolves a remote URL using a global "url..insteadOf" alias', async () => { const repository = new MockRepository();