@@ -16,6 +16,8 @@ import {
1616 getCloneDestinationBrowsePath ,
1717 getCloneDestinationPath ,
1818 getCloneDirectoryName ,
19+ getDefaultCloneUrl ,
20+ normalizePastedCloneUrl ,
1921 resolveAddProjectPath ,
2022 sortAddProjectProviderSources ,
2123} from "./projects.ts" ;
@@ -46,6 +48,46 @@ describe("add project shared logic", () => {
4648 expect ( getCloneDirectoryName ( null ) ) . toBe ( "" ) ;
4749 } ) ;
4850
51+ it ( "routes owner/repository shorthand to GitHub over HTTPS" , ( ) => {
52+ expect ( normalizePastedCloneUrl ( "imputnet/helium" ) ) . toBe (
53+ "https://github.com/imputnet/helium.git" ,
54+ ) ;
55+ expect ( normalizePastedCloneUrl ( " pingdotgg/t3code " ) ) . toBe (
56+ "https://github.com/pingdotgg/t3code.git" ,
57+ ) ;
58+ } ) ;
59+
60+ it ( "keeps explicit clone URLs and local paths unchanged" , ( ) => {
61+ expect ( normalizePastedCloneUrl ( "https://gitlab.com/group/project.git" ) ) . toBe (
62+ "https://gitlab.com/group/project.git" ,
63+ ) ;
64+ expect ( normalizePastedCloneUrl ( "git@github.com:owner/repo.git" ) ) . toBe (
65+ "git@github.com:owner/repo.git" ,
66+ ) ;
67+ expect ( normalizePastedCloneUrl ( "group/subgroup/project" ) ) . toBe ( "group/subgroup/project" ) ;
68+ expect ( normalizePastedCloneUrl ( "/srv/git/repo.git" ) ) . toBe ( "/srv/git/repo.git" ) ;
69+ } ) ;
70+
71+ it ( "uses HTTPS for repositories selected through a provider" , ( ) => {
72+ expect (
73+ getDefaultCloneUrl ( {
74+ provider : "github" ,
75+ url : "https://github.com/imputnet/helium" ,
76+ sshUrl : "git@github.com:imputnet/helium.git" ,
77+ } ) ,
78+ ) . toBe ( "https://github.com/imputnet/helium" ) ;
79+ } ) ;
80+
81+ it ( "preserves existing clone transport behavior for other providers" , ( ) => {
82+ expect (
83+ getDefaultCloneUrl ( {
84+ provider : "gitlab" ,
85+ url : "https://gitlab.com/group/project.git" ,
86+ sshUrl : "git@gitlab.com:group/project.git" ,
87+ } ) ,
88+ ) . toBe ( "git@gitlab.com:group/project.git" ) ;
89+ } ) ;
90+
4991 it ( "derives the clone folder name from any pasted clone URL" , ( ) => {
5092 expect ( getCloneDirectoryName ( "https://github.com/owner/repo.git" ) ) . toBe ( "repo" ) ;
5193 expect ( getCloneDirectoryName ( "https://github.com/owner/repo" ) ) . toBe ( "repo" ) ;
0 commit comments