|
1 | | -import { HostingIntegrationId, IssueIntegrationId } from '../../../constants.integrations'; |
| 1 | +import { HostingIntegrationId, IssueIntegrationId, SelfHostedIntegrationId } from '../../../constants.integrations'; |
2 | 2 | import type { GitReference } from '../../../git/models/reference'; |
3 | 3 | import { RemoteResourceType } from '../../../git/models/remoteResource'; |
4 | 4 | import type { Repository } from '../../../git/models/repository'; |
| 5 | +import type { GkProviderId } from '../../../git/models/repositoryIdentities'; |
| 6 | +import type { RemoteProviderId } from '../../../git/remotes/remoteProvider'; |
5 | 7 | import { isGitReference } from '../../../git/utils/reference.utils'; |
6 | 8 | import { remoteProviderIdToIntegrationId } from '../../../plus/integrations/integrationService'; |
| 9 | +import type { Unbrand } from '../../../system/brand'; |
7 | 10 | import { getSettledValue } from '../../../system/promise'; |
8 | 11 | import { isWebviewItemContext, isWebviewItemGroupContext } from '../../../system/webview'; |
9 | 12 | import type { |
10 | 13 | GraphBranchContextValue, |
11 | 14 | GraphCommitContextValue, |
12 | 15 | GraphContributorContextValue, |
| 16 | + GraphHostingServiceType, |
13 | 17 | GraphIssueContextValue, |
14 | 18 | GraphIssueTrackerType, |
15 | 19 | GraphItemContext, |
@@ -139,22 +143,93 @@ export function hasGitReference(o: unknown): o is { ref: GitReference } { |
139 | 143 | return isGitReference(o.ref); |
140 | 144 | } |
141 | 145 |
|
| 146 | +export function toGraphHostingServiceType(id: string): GraphHostingServiceType | undefined { |
| 147 | + switch (id) { |
| 148 | + case 'github' satisfies RemoteProviderId: |
| 149 | + case 'github' satisfies Unbrand<GkProviderId>: |
| 150 | + case HostingIntegrationId.GitHub: |
| 151 | + return 'github'; |
| 152 | + |
| 153 | + case 'cloud-github-enterprise' satisfies RemoteProviderId: |
| 154 | + case 'githubEnterprise' satisfies Unbrand<GkProviderId>: |
| 155 | + case SelfHostedIntegrationId.CloudGitHubEnterprise: |
| 156 | + return 'githubEnterprise'; |
| 157 | + |
| 158 | + case 'gitlab' satisfies RemoteProviderId: |
| 159 | + case 'gitlab' satisfies Unbrand<GkProviderId>: |
| 160 | + case HostingIntegrationId.GitLab: |
| 161 | + return 'gitlab'; |
| 162 | + |
| 163 | + case 'cloud-gitlab-self-hosted' satisfies RemoteProviderId: |
| 164 | + case 'gitlabSelfHosted' satisfies Unbrand<GkProviderId>: |
| 165 | + case SelfHostedIntegrationId.CloudGitLabSelfHosted: |
| 166 | + return 'gitlabSelfHosted'; |
| 167 | + |
| 168 | + case 'azure-devops' satisfies RemoteProviderId: |
| 169 | + case 'azureDevops' satisfies Unbrand<GkProviderId>: |
| 170 | + case 'azure': |
| 171 | + case HostingIntegrationId.AzureDevOps: |
| 172 | + return 'azureDevops'; |
| 173 | + |
| 174 | + case 'bitbucket' satisfies RemoteProviderId: |
| 175 | + case 'bitbucket' satisfies Unbrand<GkProviderId>: |
| 176 | + case HostingIntegrationId.Bitbucket: |
| 177 | + return 'bitbucket'; |
| 178 | + |
| 179 | + case 'bitbucket-server' satisfies RemoteProviderId: |
| 180 | + case 'bitbucketServer' satisfies Unbrand<GkProviderId>: |
| 181 | + case SelfHostedIntegrationId.BitbucketServer: |
| 182 | + return 'bitbucketServer'; |
| 183 | + |
| 184 | + default: |
| 185 | + return undefined; |
| 186 | + } |
| 187 | +} |
| 188 | + |
142 | 189 | export function toGraphIssueTrackerType(id: string): GraphIssueTrackerType | undefined { |
143 | 190 | switch (id) { |
| 191 | + case 'github' satisfies RemoteProviderId: |
| 192 | + case 'github' satisfies Unbrand<GkProviderId>: |
144 | 193 | case HostingIntegrationId.GitHub: |
145 | 194 | return 'github'; |
| 195 | + |
| 196 | + case 'cloud-github-enterprise' satisfies RemoteProviderId: |
| 197 | + case 'githubEnterprise' satisfies Unbrand<GkProviderId>: |
| 198 | + case SelfHostedIntegrationId.CloudGitHubEnterprise: |
| 199 | + return 'githubEnterprise'; |
| 200 | + |
| 201 | + case 'gitlab' satisfies RemoteProviderId: |
| 202 | + case 'gitlab' satisfies Unbrand<GkProviderId>: |
146 | 203 | case HostingIntegrationId.GitLab: |
147 | 204 | return 'gitlab'; |
| 205 | + |
| 206 | + case 'cloud-gitlab-self-hosted' satisfies RemoteProviderId: |
| 207 | + case 'gitlabSelfHosted' satisfies Unbrand<GkProviderId>: |
| 208 | + case SelfHostedIntegrationId.CloudGitLabSelfHosted: |
| 209 | + return 'gitlabSelfHosted'; |
| 210 | + |
| 211 | + case 'azure-devops' satisfies RemoteProviderId: |
| 212 | + case 'azureDevops' satisfies Unbrand<GkProviderId>: |
| 213 | + case 'azure': |
| 214 | + case HostingIntegrationId.AzureDevOps: |
| 215 | + return 'azureDevops'; |
| 216 | + |
| 217 | + case 'bitbucket' satisfies RemoteProviderId: |
| 218 | + case 'bitbucket' satisfies Unbrand<GkProviderId>: |
| 219 | + case HostingIntegrationId.Bitbucket: |
| 220 | + return 'bitbucket'; |
| 221 | + |
| 222 | + // case 'bitbucket-server' satisfies RemoteProviderId: |
| 223 | + // case 'bitbucketServer' satisfies Unbrand<GkProviderId>: |
| 224 | + // case SelfHostedIntegrationId.BitbucketServer: |
| 225 | + // return 'bitbucketServer'; |
| 226 | + |
148 | 227 | case IssueIntegrationId.Jira: |
149 | 228 | return 'jiraCloud'; |
150 | | - case HostingIntegrationId.AzureDevOps: |
151 | | - case 'azure': |
152 | | - case 'azure-devops': |
153 | | - // TODO: Remove the casting once this is officially recognized by the component |
154 | | - return 'azureDevops' as GraphIssueTrackerType; |
155 | | - case 'bitbucket': |
156 | | - // TODO: Remove the casting once this is officially recognized by the component |
157 | | - return HostingIntegrationId.Bitbucket as GraphIssueTrackerType; |
| 229 | + |
| 230 | + // case IssueIntegrationId.JiraServer: |
| 231 | + // return 'jiraServer'; |
| 232 | + |
158 | 233 | default: |
159 | 234 | return undefined; |
160 | 235 | } |
|
0 commit comments