Skip to content
14 changes: 7 additions & 7 deletions docs/telemetry-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ or
```typescript
{
'hostingProvider.key': string,
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'gitlab-self-hosted'
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted'
}
```

Expand All @@ -330,7 +330,7 @@ or
```typescript
{
'hostingProvider.key': string,
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'gitlab-self-hosted'
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted'
}
```

Expand All @@ -341,7 +341,7 @@ or
```typescript
{
'issueProvider.key': string,
'issueProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'gitlab-self-hosted'
'issueProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted'
}
```

Expand All @@ -352,7 +352,7 @@ or
```typescript
{
'issueProvider.key': string,
'issueProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'gitlab-self-hosted'
'issueProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted'
}
```

Expand All @@ -373,7 +373,7 @@ or

```typescript
{
'integration.id': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello'
'integration.id': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted'
}
```

Expand Down Expand Up @@ -1465,7 +1465,7 @@ void
```typescript
{
'hostingProvider.key': string,
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'gitlab-self-hosted',
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted',
// @deprecated: true
'remoteProviders.key': string
}
Expand All @@ -1478,7 +1478,7 @@ void
```typescript
{
'hostingProvider.key': string,
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'gitlab-self-hosted',
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'jira' | 'trello' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted',
// @deprecated: true
'remoteProviders.key': string
}
Expand Down
8 changes: 8 additions & 0 deletions src/constants.integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum HostingIntegrationId {

export enum SelfHostedIntegrationId {
GitHubEnterprise = 'github-enterprise',
CloudGitHubEnterprise = 'cloud-github-enterprise',
GitLabSelfHosted = 'gitlab-self-hosted',
}

Expand All @@ -20,6 +21,7 @@ export type IntegrationId = HostingIntegrationId | IssueIntegrationId | SelfHost
export const supportedOrderedCloudIssueIntegrationIds = [IssueIntegrationId.Jira];
export const supportedOrderedCloudIntegrationIds = [
HostingIntegrationId.GitHub,
SelfHostedIntegrationId.CloudGitHubEnterprise,
HostingIntegrationId.GitLab,
IssueIntegrationId.Jira,
];
Expand All @@ -45,6 +47,12 @@ export const supportedCloudIntegrationDescriptors: IntegrationDescriptor[] = [
icon: 'gl-provider-github',
supports: ['prs', 'issues'],
},
{
id: SelfHostedIntegrationId.CloudGitHubEnterprise,
name: 'GitHub Enterprise',
icon: 'gl-provider-github',
supports: ['prs', 'issues'],
},
{
id: HostingIntegrationId.GitLab,
name: 'GitLab',
Expand Down
11 changes: 11 additions & 0 deletions src/constants.storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type GlobalStorage = {
'launchpadView:groups:expanded': StoredLaunchpadGroup[];
'graph:searchMode': StoredGraphSearchMode;
'views:scm:grouped:welcome:dismissed': boolean;
'integrations:configured': StoredIntegrationConfigurations;
} & { [key in `plus:preview:${FeaturePreviews}:usages`]: StoredFeaturePreviewUsagePeriod[] } & {
[key in `confirm:ai:tos:${AIProviders}`]: boolean;
} & {
Expand All @@ -88,6 +89,16 @@ export type GlobalStorage = {
[key in `jira:${string}:projects`]: Stored<StoredJiraProject[] | undefined>;
};

export type StoredIntegrationConfigurations = Record<string, StoredConfiguredIntegrationDescriptor[] | undefined>;

export interface StoredConfiguredIntegrationDescriptor {
cloud: boolean;
integrationId: IntegrationId;
domain?: string;
expiresAt?: string;
scopes: string;
}

export type DeprecatedWorkspaceStorage = {
/** @deprecated use `confirm:ai:tos:${AIProviders}` */
'confirm:sendToOpenAI': boolean;
Expand Down
1 change: 1 addition & 0 deletions src/env/node/git/sub-providers/remotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class RemotesGitSubProvider extends RemotesGitProviderBase implements Git
async function load(this: RemotesGitSubProvider): Promise<GitRemote[]> {
const providers = loadRemoteProviders(
configuration.get('remotes', this.container.git.getRepository(repoPath!)?.folder?.uri ?? null),
this.container.integrations.getConfiguredIntegrationDescriptors(),
);

try {
Expand Down
35 changes: 33 additions & 2 deletions src/git/remotes/remoteProviders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { RemotesConfig } from '../../config';
import { SelfHostedIntegrationId } from '../../constants.integrations';
import type { Container } from '../../container';
import type { ConfiguredIntegrationDescriptor } from '../../plus/integrations/authentication/models';
import { Logger } from '../../system/logger';
import { configuration } from '../../system/vscode/configuration';
import { AzureDevOpsRemote } from './azure-devops';
Expand Down Expand Up @@ -73,7 +75,10 @@ const builtInProviders: RemoteProviders = [
},
];

export function loadRemoteProviders(cfg: RemotesConfig[] | null | undefined): RemoteProviders {
export function loadRemoteProviders(
cfg: RemotesConfig[] | null | undefined,
configuredIntegrations?: ConfiguredIntegrationDescriptor[],
): RemoteProviders {
const providers: RemoteProviders = [];

if (cfg?.length) {
Expand All @@ -97,6 +102,29 @@ export function loadRemoteProviders(cfg: RemotesConfig[] | null | undefined): Re
}
}

if (configuredIntegrations?.length) {
for (const ci of configuredIntegrations) {
if (ci.integrationId === SelfHostedIntegrationId.CloudGitHubEnterprise && ci.domain) {
const matcher = ci.domain.toLocaleLowerCase();
const providerCreator = (_container: Container, domain: string, path: string) =>
new GitHubRemote(domain, path);
const provider = {
custom: false,
matcher: matcher,
creator: providerCreator,
};

const indexOfCustomDuplication: number = providers.findIndex(p => p.matcher === matcher);

if (indexOfCustomDuplication !== -1) {
providers[indexOfCustomDuplication] = provider;
} else {
providers.push(provider);
}
}
}
}

providers.push(...builtInProviders);

return providers;
Expand Down Expand Up @@ -141,7 +169,10 @@ export function getRemoteProviderMatcher(
providers?: RemoteProviders,
): (url: string, domain: string, path: string) => RemoteProvider | undefined {
if (providers == null) {
providers = loadRemoteProviders(configuration.get('remotes', null));
providers = loadRemoteProviders(
configuration.get('remotes', null),
container.integrations.getConfiguredIntegrationDescriptors(),
);
}

return (url: string, domain: string, path: string) =>
Expand Down
19 changes: 16 additions & 3 deletions src/plus/integrations/authentication/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import { wrapForForcedInsecureSSL } from '@env/fetch';
import { HostingIntegrationId, SelfHostedIntegrationId } from '../../../constants.integrations';
import type { Sources } from '../../../constants.telemetry';
import type { Container } from '../../../container';
import type { IntegrationAuthenticationSessionDescriptor } from './integrationAuthentication';
import type {
IntegrationAuthenticationService,
IntegrationAuthenticationSessionDescriptor,
} from './integrationAuthentication';
import {
CloudIntegrationAuthenticationProvider,
LocalIntegrationAuthenticationProvider,
} from './integrationAuthentication';
import type { ProviderAuthenticationSession } from './models';

export class GitHubAuthenticationProvider extends CloudIntegrationAuthenticationProvider<HostingIntegrationId.GitHub> {
constructor(container: Container) {
super(container);
constructor(container: Container, authenticationService: IntegrationAuthenticationService) {
super(container, authenticationService);
this.disposables.push(
authentication.onDidChangeSessions(e => {
if (e.provider.id === this.authProviderId) {
Expand Down Expand Up @@ -69,6 +72,16 @@ export class GitHubAuthenticationProvider extends CloudIntegrationAuthentication
}
}

export class GitHubEnterpriseCloudAuthenticationProvider extends CloudIntegrationAuthenticationProvider<SelfHostedIntegrationId.CloudGitHubEnterprise> {
protected override getCompletionInputTitle(): string {
throw new Error('Connect to GitHub Enterprise');
}

protected override get authProviderId(): SelfHostedIntegrationId.CloudGitHubEnterprise {
return SelfHostedIntegrationId.CloudGitHubEnterprise;
}
}

export class GitHubEnterpriseAuthenticationProvider extends LocalIntegrationAuthenticationProvider<SelfHostedIntegrationId.GitHubEnterprise> {
protected override get authProviderId(): SelfHostedIntegrationId.GitHubEnterprise {
return SelfHostedIntegrationId.GitHubEnterprise;
Expand Down
8 changes: 6 additions & 2 deletions src/plus/integrations/authentication/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { env, ThemeIcon, Uri, window } from 'vscode';
import type { SelfHostedIntegrationId } from '../../../constants.integrations';
import { HostingIntegrationId } from '../../../constants.integrations';
import type { Container } from '../../../container';
import type { IntegrationAuthenticationSessionDescriptor } from './integrationAuthentication';
import type {
IntegrationAuthenticationService,
IntegrationAuthenticationSessionDescriptor,
} from './integrationAuthentication';
import {
CloudIntegrationAuthenticationProvider,
LocalIntegrationAuthenticationProvider,
Expand All @@ -15,9 +18,10 @@ type GitLabId = HostingIntegrationId.GitLab | SelfHostedIntegrationId.GitLabSelf
export class GitLabLocalAuthenticationProvider extends LocalIntegrationAuthenticationProvider<GitLabId> {
constructor(
container: Container,
authenticationService: IntegrationAuthenticationService,
protected readonly authProviderId: GitLabId,
) {
super(container);
super(container, authenticationService);
}

override async createSession(
Expand Down
Loading
Loading