@@ -3,6 +3,7 @@ import { describe, expect, it } from "vite-plus/test";
33import {
44 detectSourceControlProviderFromRemoteUrl ,
55 getChangeRequestTerminologyForKind ,
6+ isSshRemoteUrl ,
67 resolveChangeRequestPresentation ,
78} from "./sourceControl.ts" ;
89
@@ -120,4 +121,42 @@ describe("detectSourceControlProviderFromRemoteUrl", () => {
120121 ) ?. kind ,
121122 ) . toBe ( "unknown" ) ;
122123 } ) ;
124+
125+ it ( "detects SSH remotes with non-git SSH users (e.g. gitlab@, deploy@)" , ( ) => {
126+ expect (
127+ detectSourceControlProviderFromRemoteUrl ( "[email protected] :group/project.git" ) ?. kind , 128+ ) . toBe ( "gitlab" ) ;
129+ expect (
130+ detectSourceControlProviderFromRemoteUrl ( "[email protected] :group/project.git" ) 131+ ?. baseUrl ,
132+ ) . toBe ( "https://gitlab.example.com" ) ;
133+ expect ( detectSourceControlProviderFromRemoteUrl ( "[email protected] :owner/repo.git" ) ?. kind ) . toBe ( 134+ "github" ,
135+ ) ;
136+ expect (
137+ detectSourceControlProviderFromRemoteUrl ( "[email protected] :workspace/repo.git" ) ?. kind , 138+ ) . toBe ( "bitbucket" ) ;
139+ } ) ;
140+ } ) ;
141+
142+ describe ( "isSshRemoteUrl" , ( ) => {
143+ it ( "recognises SCP-like SSH URLs with any SSH user prefix" , ( ) => {
144+ expect ( isSshRemoteUrl ( "[email protected] :owner/repo.git" ) ) . toBe ( true ) ; 145+ expect ( isSshRemoteUrl ( "[email protected] :group/project.git" ) ) . toBe ( true ) ; 146+ expect ( isSshRemoteUrl ( "[email protected] :workspace/repo.git" ) ) . toBe ( true ) ; 147+ } ) ;
148+
149+ it ( "recognises ssh:// URLs with any case" , ( ) => {
150+ expect ( isSshRemoteUrl ( "ssh://[email protected] /group/project.git" ) ) . toBe ( true ) ; 151+ expect ( isSshRemoteUrl ( "ssh://[email protected] :22/group/project.git" ) ) . toBe ( true ) ; 152+ expect ( isSshRemoteUrl ( "SSH://[email protected] /group/project.git" ) ) . toBe ( true ) ; 153+ expect ( isSshRemoteUrl ( "SsH://[email protected] /group/project.git" ) ) . toBe ( true ) ; 154+ } ) ;
155+
156+ it ( "returns false for HTTPS, local paths, and SCP-like paths without a colon" , ( ) => {
157+ expect ( isSshRemoteUrl ( "https://gitlab.example.com/group/project.git" ) ) . toBe ( false ) ;
158+ expect ( isSshRemoteUrl ( "/home/user/repos/project" ) ) . toBe ( false ) ;
159+ expect ( isSshRemoteUrl ( "" ) ) . toBe ( false ) ;
160+ expect ( isSshRemoteUrl ( "[email protected] /project/repo" ) ) . toBe ( false ) ; 161+ } ) ;
123162} ) ;
0 commit comments