Skip to content

Commit f884fc6

Browse files
Supports GitHub Enterprise (GKDev) in Launchpad
(#3923, #3932) --------- Co-authored-by: Ramin Tadayon <[email protected]>
1 parent 40f8024 commit f884fc6

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

src/git/remotes/remoteProvider.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type RemoteProviderId =
2020
| 'gerrit'
2121
| 'gitea'
2222
| 'github'
23+
| 'cloud-github-enterprise'
2324
| 'gitlab'
2425
| 'google-source';
2526

src/plus/integrations/integrationService.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ export class IntegrationService implements Disposable {
451451
return key == null ? this._connectedCache.size !== 0 : this._connectedCache.has(key);
452452
}
453453

454-
get(id: SupportedHostingIntegrationIds): Promise<HostingIntegration>;
454+
get(
455+
id: SupportedHostingIntegrationIds | SelfHostedIntegrationId.CloudGitHubEnterprise,
456+
): Promise<HostingIntegration>;
455457
get(id: SupportedIssueIntegrationIds): Promise<IssueIntegration>;
456458
get(id: SupportedSelfHostedIntegrationIds, domain: string): Promise<HostingIntegration>;
457459
get(id: SupportedIntegrationIds, domain?: string): Promise<Integration>;
@@ -760,8 +762,10 @@ export class IntegrationService implements Disposable {
760762
@log<IntegrationService['getMyCurrentAccounts']>({
761763
args: { 0: integrationIds => (integrationIds?.length ? integrationIds.join(',') : '<undefined>') },
762764
})
763-
async getMyCurrentAccounts(integrationIds: HostingIntegrationId[]): Promise<Map<HostingIntegrationId, Account>> {
764-
const accounts = new Map<HostingIntegrationId, Account>();
765+
async getMyCurrentAccounts(
766+
integrationIds: (HostingIntegrationId | SelfHostedIntegrationId.CloudGitHubEnterprise)[],
767+
): Promise<Map<HostingIntegrationId | SelfHostedIntegrationId.CloudGitHubEnterprise, Account>> {
768+
const accounts = new Map<HostingIntegrationId | SelfHostedIntegrationId.CloudGitHubEnterprise, Account>();
765769
await Promise.allSettled(
766770
integrationIds.map(async integrationId => {
767771
const integration = await this.get(integrationId);
@@ -780,13 +784,16 @@ export class IntegrationService implements Disposable {
780784
args: { 0: integrationIds => (integrationIds?.length ? integrationIds.join(',') : '<undefined>'), 1: false },
781785
})
782786
async getMyPullRequests(
783-
integrationIds?: HostingIntegrationId[],
787+
integrationIds?: (HostingIntegrationId | SelfHostedIntegrationId.CloudGitHubEnterprise)[],
784788
cancellation?: CancellationToken,
785789
silent?: boolean,
786790
): Promise<IntegrationResult<SearchedPullRequest[] | undefined>> {
787791
const integrations: Map<HostingIntegration, ResourceDescriptor[] | undefined> = new Map();
788792
for (const integrationId of integrationIds?.length ? integrationIds : Object.values(HostingIntegrationId)) {
789-
const integration = await this.get(integrationId);
793+
let integration;
794+
try {
795+
integration = await this.get(integrationId);
796+
} catch {}
790797
if (integration == null) continue;
791798

792799
integrations.set(integration, undefined);

src/plus/integrations/providers/utils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ function fromStringToEntityIdentifierProviderType(str: string): EntityIdentifier
9292
switch (str) {
9393
case 'github':
9494
return EntityIdentifierProviderType.Github;
95+
case 'cloud-github-enterprise':
96+
return EntityIdentifierProviderType.GithubEnterprise;
9597
case 'gitlab':
9698
return EntityIdentifierProviderType.Gitlab;
9799
case 'jira':

src/plus/launchpad/enrichmentService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ const supportedRemoteProvidersToEnrich: Record<RemoteProvider['id'], EnrichedIte
217217
gerrit: undefined,
218218
gitea: undefined,
219219
github: 'github',
220+
'cloud-github-enterprise': 'github',
220221
gitlab: 'gitlab',
221222
'google-source': undefined,
222223
};

src/plus/launchpad/launchpad.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,7 @@ function getOpenOnGitProviderQuickInputButton(integrationId: string): QuickInput
15671567
return OpenOnGitLabQuickInputButton;
15681568
case HostingIntegrationId.GitHub:
15691569
case SelfHostedIntegrationId.GitHubEnterprise:
1570+
case SelfHostedIntegrationId.CloudGitHubEnterprise:
15701571
return OpenOnGitHubQuickInputButton;
15711572
default:
15721573
return undefined;
@@ -1585,6 +1586,7 @@ function getIntegrationTitle(integrationId: string): string {
15851586
return 'GitLab';
15861587
case HostingIntegrationId.GitHub:
15871588
case SelfHostedIntegrationId.GitHubEnterprise:
1589+
case SelfHostedIntegrationId.CloudGitHubEnterprise:
15881590
return 'GitHub';
15891591
default:
15901592
return integrationId;

src/plus/launchpad/launchpadProvider.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Disposable, env, EventEmitter, Uri, window } from 'vscode';
88
import { md5 } from '@env/crypto';
99
import { GlCommand } from '../../constants.commands';
1010
import type { IntegrationId } from '../../constants.integrations';
11-
import { HostingIntegrationId } from '../../constants.integrations';
11+
import { HostingIntegrationId, SelfHostedIntegrationId } from '../../constants.integrations';
1212
import type { Container } from '../../container';
1313
import { CancellationError } from '../../errors';
1414
import { openComparisonChanges } from '../../git/actions/commit';
@@ -109,7 +109,8 @@ type PullRequestsWithSuggestionCounts = {
109109

110110
export type LaunchpadRefreshEvent = LaunchpadCategorizedResult;
111111

112-
export const supportedLaunchpadIntegrations = [HostingIntegrationId.GitHub, HostingIntegrationId.GitLab];
112+
export const supportedLaunchpadIntegrations: (HostingIntegrationId | SelfHostedIntegrationId.CloudGitHubEnterprise)[] =
113+
[HostingIntegrationId.GitHub, SelfHostedIntegrationId.CloudGitHubEnterprise, HostingIntegrationId.GitLab];
113114
type SupportedLaunchpadIntegrationIds = (typeof supportedLaunchpadIntegrations)[number];
114115
function isSupportedLaunchpadIntegrationId(id: string): id is SupportedLaunchpadIntegrationIds {
115116
return supportedLaunchpadIntegrations.includes(id as SupportedLaunchpadIntegrationIds);

0 commit comments

Comments
 (0)