diff --git a/CHANGELOG.md b/CHANGELOG.md index 78ecc96659f2d..8514f386772d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Added +- Adds the ability to search for GitHub Enterprise and GitLab Self-Managed pull requests by URL in the main step of Launchpad - Adds OpenRouter support for GitLens' AI features ([#3906](https://github.com/gitkraken/vscode-gitlens/issues/3906)) - Adds OpenAI GPT-4.1, GPT-4.1 mini, GPT-4.1 nano, o4 mini, and o3 models for GitLens' AI features ([#4235](https://github.com/gitkraken/vscode-gitlens/issues/4235)) - Adds _Open File at Revision from Remote_ command to open the specific file revision from a remote file URL diff --git a/src/git/utils/pullRequest.utils.ts b/src/git/utils/pullRequest.utils.ts index 5eaae38f5ce0d..9ef568c1e5dd4 100644 --- a/src/git/utils/pullRequest.utils.ts +++ b/src/git/utils/pullRequest.utils.ts @@ -1,4 +1,4 @@ -import type { HostingIntegrationId } from '../../constants.integrations'; +import type { HostingIntegrationId, SelfHostedIntegrationId } from '../../constants.integrations'; import type { PullRequest, PullRequestComparisonRefs, @@ -9,7 +9,7 @@ import type { import { shortenRevision } from './revision.utils'; export interface PullRequestUrlIdentity { - provider?: HostingIntegrationId; + provider?: SelfHostedIntegrationId | HostingIntegrationId; ownerAndRepo?: string; prNumber: string; diff --git a/src/plus/integrations/providers/github.ts b/src/plus/integrations/providers/github.ts index 097f30fc2f28a..054a15693357a 100644 --- a/src/plus/integrations/providers/github.ts +++ b/src/plus/integrations/providers/github.ts @@ -13,8 +13,9 @@ import { log } from '../../../system/decorators/log'; import { ensurePaidPlan } from '../../gk/utils/-webview/plus.utils'; import type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider'; import type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService'; -import type { RepositoryDescriptor, SupportedIntegrationIds } from '../integration'; +import type { RepositoryDescriptor } from '../integration'; import { HostingIntegration } from '../integration'; +import type { GitHubRelatedIntegrationIds } from './github/github.utils'; import { getGitHubPullRequestIdentityFromMaybeUrl } from './github/github.utils'; import { providersMetadata } from './models'; import type { ProvidersApi } from './providersApi'; @@ -38,7 +39,7 @@ const cloudEnterpriseAuthProvider: IntegrationAuthenticationProviderDescriptor = export type GitHubRepositoryDescriptor = RepositoryDescriptor; -abstract class GitHubIntegrationBase extends HostingIntegration< +abstract class GitHubIntegrationBase extends HostingIntegration< ID, GitHubRepositoryDescriptor > { @@ -260,6 +261,10 @@ abstract class GitHubIntegrationBase extends baseUrl: this.apiBaseUrl, }); } + + protected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined { + return getGitHubPullRequestIdentityFromMaybeUrl(search, this.id); + } } export class GitHubIntegration extends GitHubIntegrationBase { @@ -294,10 +299,6 @@ export class GitHubIntegration extends GitHubIntegrationBase extends HostingIntegration { +abstract class GitLabIntegrationBase extends HostingIntegration< + ID, + GitLabRepositoryDescriptor +> { protected abstract get apiBaseUrl(): string; protected override async getProviderAccountForCommit( @@ -409,7 +408,7 @@ abstract class GitLabIntegrationBase< } protected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined { - return getGitLabPullRequestIdentityFromMaybeUrl(search); + return getGitLabPullRequestIdentityFromMaybeUrl(search, this.id); } } diff --git a/src/plus/integrations/providers/gitlab/__tests__/gitlab.utils.test.ts b/src/plus/integrations/providers/gitlab/__tests__/gitlab.utils.test.ts index 9e6699586080c..45b17593b483b 100644 --- a/src/plus/integrations/providers/gitlab/__tests__/gitlab.utils.test.ts +++ b/src/plus/integrations/providers/gitlab/__tests__/gitlab.utils.test.ts @@ -10,7 +10,7 @@ suite('Test GitLab PR URL parsing to identity: getPullRequestIdentityFromMaybeUr : { ownerAndRepo: ownerAndRepo, prNumber: prNumber, - provider: 'gitlab', + provider: undefined, }, `Parse: ${message} (${JSON.stringify(query)})`, ); diff --git a/src/plus/integrations/providers/gitlab/gitlab.utils.ts b/src/plus/integrations/providers/gitlab/gitlab.utils.ts index e3757895d664b..ef4a37a40b29e 100644 --- a/src/plus/integrations/providers/gitlab/gitlab.utils.ts +++ b/src/plus/integrations/providers/gitlab/gitlab.utils.ts @@ -2,16 +2,29 @@ // That's why this file has been created that can collect more simple functions which // don't require Container and can be tested. -import { HostingIntegrationId } from '../../../../constants.integrations'; +import type { HostingIntegrationId, SelfHostedIntegrationId } from '../../../../constants.integrations'; import type { PullRequestUrlIdentity } from '../../../../git/utils/pullRequest.utils'; +export type GitLabRelatedIntegrationIds = + | HostingIntegrationId.GitLab + | SelfHostedIntegrationId.GitLabSelfHosted + | SelfHostedIntegrationId.CloudGitLabSelfHosted; + export function isMaybeGitLabPullRequestUrl(url: string): boolean { return getGitLabPullRequestIdentityFromMaybeUrl(url) != null; } export function getGitLabPullRequestIdentityFromMaybeUrl( search: string, -): (PullRequestUrlIdentity & { provider: HostingIntegrationId.GitLab }) | undefined { +): (PullRequestUrlIdentity & { provider: undefined }) | undefined; +export function getGitLabPullRequestIdentityFromMaybeUrl( + search: string, + id: GitLabRelatedIntegrationIds, +): (PullRequestUrlIdentity & { provider: GitLabRelatedIntegrationIds }) | undefined; +export function getGitLabPullRequestIdentityFromMaybeUrl( + search: string, + id?: GitLabRelatedIntegrationIds, +): (PullRequestUrlIdentity & { provider: GitLabRelatedIntegrationIds | undefined }) | undefined { let ownerAndRepo: string | undefined = undefined; let prNumber: string | undefined = undefined; @@ -28,7 +41,5 @@ export function getGitLabPullRequestIdentityFromMaybeUrl( } } - return prNumber != null - ? { ownerAndRepo: ownerAndRepo, prNumber: prNumber, provider: HostingIntegrationId.GitLab } - : undefined; + return prNumber != null ? { ownerAndRepo: ownerAndRepo, prNumber: prNumber, provider: id } : undefined; }