2
2
// That's why this file has been created that can collect more simple functions which
3
3
// don't require Container and can be tested.
4
4
5
- import { HostingIntegrationId } from '../../../../constants.integrations' ;
5
+ import type { HostingIntegrationId , SelfHostedIntegrationId } from '../../../../constants.integrations' ;
6
6
import type { PullRequestUrlIdentity } from '../../../../git/utils/pullRequest.utils' ;
7
7
8
+ export type GitLabRelatedIntegrationIds =
9
+ | HostingIntegrationId . GitLab
10
+ | SelfHostedIntegrationId . GitLabSelfHosted
11
+ | SelfHostedIntegrationId . CloudGitLabSelfHosted ;
12
+
8
13
export function isMaybeGitLabPullRequestUrl ( url : string ) : boolean {
9
14
return getGitLabPullRequestIdentityFromMaybeUrl ( url ) != null ;
10
15
}
11
16
12
17
export function getGitLabPullRequestIdentityFromMaybeUrl (
13
18
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 {
15
28
let ownerAndRepo : string | undefined = undefined ;
16
29
let prNumber : string | undefined = undefined ;
17
30
@@ -28,7 +41,5 @@ export function getGitLabPullRequestIdentityFromMaybeUrl(
28
41
}
29
42
}
30
43
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 ;
34
45
}
0 commit comments