Skip to content

Commit a83abb6

Browse files
committed
Refactors integration ID lookup to use provider directly
Replaces passing the entire remote object with passing only its provider when determining integration IDs. Simplifies function signatures and clarifies usage, reducing unnecessary coupling to the remote. (#4478, #4516)
1 parent 00b620a commit a83abb6

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/git/models/remote.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class GitRemote<TProvider extends RemoteProvider | undefined = RemoteProv
5151
get maybeIntegrationConnected(): boolean | undefined {
5252
if (!this.provider?.id) return false;
5353

54-
const integrationId = getIntegrationIdForRemote(this);
54+
const integrationId = getIntegrationIdForRemote(this.provider);
5555
if (integrationId == null) return false;
5656

5757
// Special case for GitHub, since we support the legacy GitHub integration
@@ -105,7 +105,7 @@ export class GitRemote<TProvider extends RemoteProvider | undefined = RemoteProv
105105
}
106106

107107
async getIntegration(): Promise<GitHostIntegration | undefined> {
108-
const integrationId = getIntegrationIdForRemote(this);
108+
const integrationId = getIntegrationIdForRemote(this.provider);
109109
return integrationId && this.container.integrations.get(integrationId, this.provider?.domain);
110110
}
111111

@@ -125,7 +125,7 @@ export class GitRemote<TProvider extends RemoteProvider | undefined = RemoteProv
125125
}
126126

127127
supportsIntegration(): this is GitRemote<RemoteProvider> {
128-
return Boolean(getIntegrationIdForRemote(this));
128+
return Boolean(getIntegrationIdForRemote(this.provider));
129129
}
130130
}
131131

src/plus/integrations/utils/-webview/integration.utils.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {
44
GitSelfManagedHostIntegrationId,
55
IssuesCloudHostIntegrationId,
66
} from '../../../../constants.integrations';
7-
import type { GitRemote } from '../../../../git/models/remote';
8-
import type { RemoteProviderId } from '../../../../git/remotes/remoteProvider';
7+
import type { RemoteProvider, RemoteProviderId } from '../../../../git/remotes/remoteProvider';
98
import type { IntegrationConnectedKey } from '../../models/integration';
109
import { isAzureCloudDomain } from '../../providers/azureDevOps';
1110
import { isBitbucketCloudDomain } from '../../providers/bitbucket';
@@ -64,30 +63,30 @@ export function getIntegrationConnectedKey<T extends IntegrationIds>(
6463
}
6564

6665
export function getIntegrationIdForRemote(
67-
remote: GitRemote,
66+
provider: RemoteProvider | undefined,
6867
): GitCloudHostIntegrationId | GitSelfManagedHostIntegrationId | undefined {
69-
switch (remote.provider?.id) {
68+
switch (provider?.id) {
7069
case 'azure-devops':
71-
if (isAzureCloudDomain(remote.provider.domain)) {
70+
if (isAzureCloudDomain(provider.domain)) {
7271
return GitCloudHostIntegrationId.AzureDevOps;
7372
}
74-
return remote.provider.custom ? undefined : GitSelfManagedHostIntegrationId.AzureDevOpsServer;
73+
return provider.custom ? undefined : GitSelfManagedHostIntegrationId.AzureDevOpsServer;
7574
case 'bitbucket':
7675
case 'bitbucket-server':
77-
if (isBitbucketCloudDomain(remote.provider.domain)) {
76+
if (isBitbucketCloudDomain(provider.domain)) {
7877
return GitCloudHostIntegrationId.Bitbucket;
7978
}
8079
return GitSelfManagedHostIntegrationId.BitbucketServer;
8180
case 'github':
82-
if (remote.provider.domain != null && !isGitHubDotCom(remote.provider.domain)) {
83-
return remote.provider.custom
81+
if (provider.domain != null && !isGitHubDotCom(provider.domain)) {
82+
return provider.custom
8483
? GitSelfManagedHostIntegrationId.GitHubEnterprise
8584
: GitSelfManagedHostIntegrationId.CloudGitHubEnterprise;
8685
}
8786
return GitCloudHostIntegrationId.GitHub;
8887
case 'gitlab':
89-
if (remote.provider.domain != null && !isGitLabDotCom(remote.provider.domain)) {
90-
return remote.provider.custom
88+
if (provider.domain != null && !isGitLabDotCom(provider.domain)) {
89+
return provider.custom
9190
? GitSelfManagedHostIntegrationId.GitLabSelfHosted
9291
: GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;
9392
}

0 commit comments

Comments
 (0)