1+ import type { ChangeRequestProjectIdentity } from "@t3tools/source-control-core/shared/definition" ;
12import { recognizeRemoteWith } from "@t3tools/source-control-core/shared/definition" ;
23import { describe , expect , it } from "vite-plus/test" ;
34
@@ -20,6 +21,32 @@ describe("GitLab change request URLs", () => {
2021 } ) ;
2122 } ) ;
2223
24+ it ( "matches a merge request's explicit HTTP port before choosing a project" , ( ) => {
25+ const link = parse ( "https://gitlab.example.test:9443/team/project/-/merge_requests/9" ) ! ;
26+ const identity = ( remoteUrl : string ) : ChangeRequestProjectIdentity => ( {
27+ canonicalKey : "gitlab.example.test/team/project" ,
28+ displayName : "team/project" ,
29+ locator : { source : "git-remote" , remoteName : "origin" , remoteUrl } ,
30+ } ) ;
31+ const matching = identity ( "https://gitlab.example.test:9443/team/project.git" ) ;
32+ expect ( definition . isChangeRequestInRepository ( matching , link ) ) . toBe ( true ) ;
33+ expect ( definition . canReadChangeRequestOnHost ( matching , link ) ) . toBe ( true ) ;
34+ for ( const remote of [
35+ "https://gitlab.example.test:8443/team/project.git" ,
36+ "https://gitlab.example.test/team/project.git" ,
37+ ] ) {
38+ expect ( definition . isChangeRequestInRepository ( identity ( remote ) , link ) , remote ) . toBe ( false ) ;
39+ expect ( definition . canReadChangeRequestOnHost ( identity ( remote ) , link ) , remote ) . toBe ( false ) ;
40+ }
41+ expect ( link ) . toMatchObject ( {
42+ host : "gitlab.example.test" ,
43+ authority : "gitlab.example.test:9443" ,
44+ repositoryUrl : "https://gitlab.example.test:9443/team/project" ,
45+ } ) ;
46+ const ssh = identity ( "ssh://[email protected] :2222/team/project.git" ) ; 47+ expect ( definition . isChangeRequestInRepository ( ssh , link ) ) . toBe ( true ) ;
48+ } ) ;
49+
2350 it ( "keeps pull-like segments inside nested repository paths" , ( ) => {
2451 expect (
2552 parse ( "https://gitlab.example.test/group/pull/123/repo/-/merge_requests/42" ) ?. repositoryUrl ,
0 commit comments