22// That's why this file has been created that can collect more simple functions which
33// don't require Container and can be tested.
44
5- import { HostingIntegrationId } from '../../../../constants.integrations' ;
5+ import type { HostingIntegrationId , SelfHostedIntegrationId } from '../../../../constants.integrations' ;
66import type { PullRequestUrlIdentity } from '../../../../git/utils/pullRequest.utils' ;
77
8+ export type GitLabRelatedIntegrationIds =
9+ | HostingIntegrationId . GitLab
10+ | SelfHostedIntegrationId . GitLabSelfHosted
11+ | SelfHostedIntegrationId . CloudGitLabSelfHosted ;
12+
813export function isMaybeGitLabPullRequestUrl ( url : string ) : boolean {
914 return getGitLabPullRequestIdentityFromMaybeUrl ( url ) != null ;
1015}
1116
1217export function getGitLabPullRequestIdentityFromMaybeUrl (
1318 search : string ,
14- ) : ( PullRequestUrlIdentity & { provider : HostingIntegrationId . GitLab } ) | undefined {
19+ ) : ( PullRequestUrlIdentity & { provider : undefined } ) | undefined ;
20+ export function getGitLabPullRequestIdentityFromMaybeUrl (
21+ search : string ,
22+ id : GitLabRelatedIntegrationIds ,
23+ ) : ( PullRequestUrlIdentity & { provider : GitLabRelatedIntegrationIds } ) | undefined ;
24+ export function getGitLabPullRequestIdentityFromMaybeUrl (
25+ search : string ,
26+ id ?: GitLabRelatedIntegrationIds ,
27+ ) : ( PullRequestUrlIdentity & { provider : GitLabRelatedIntegrationIds | undefined } ) | undefined {
1528 let ownerAndRepo : string | undefined = undefined ;
1629 let prNumber : string | undefined = undefined ;
1730
@@ -28,7 +41,5 @@ export function getGitLabPullRequestIdentityFromMaybeUrl(
2841 }
2942 }
3043
31- return prNumber != null
32- ? { ownerAndRepo : ownerAndRepo , prNumber : prNumber , provider : HostingIntegrationId . GitLab }
33- : undefined ;
44+ return prNumber != null ? { ownerAndRepo : ownerAndRepo , prNumber : prNumber , provider : id } : undefined ;
3445}
0 commit comments