@@ -48,6 +48,46 @@ describe("selectGitHubBaseRepository", () => {
4848 ) ;
4949 } ) ;
5050
51+ it ( "honors a marked SSH alias origin over upstream" , ( ) => {
52+ for ( const url of [
53+ 54+ "ssh://[email protected] :22/me/web.git" , 55+ "git@github-work:me/web.git" ,
56+ ] ) {
57+ const input = {
58+ remotes : remotes ( [ "origin" , url ] , [ "upstream" , "https://github.com/acme/web.git" ] ) ,
59+ resolved : "remote.origin.gh-resolved base" ,
60+ } ;
61+ assert . deepStrictEqual ( select ( input ) , { owner : "me" , name : "web" } , url ) ;
62+ assert . deepStrictEqual (
63+ resolveGitHubRepository ( { ...input , hostHint : undefined , defaultHost : "github.com" } ) ,
64+ { host : "github.com" , locator : { host : "github.com" , owner : "me" , name : "web" } } ,
65+ url ,
66+ ) ;
67+ }
68+ } ) ;
69+
70+ it ( "does not honor a github.com mark on a different or unrecognized host" , ( ) => {
71+ for ( const url of [
72+ 73+ 74+ 75+ "https://github.com-scale/me/web.git" ,
76+ "git@work:me/web.git" ,
77+ ] ) {
78+ const input = {
79+ remotes : remotes ( [ "origin" , url ] , [ "upstream" , "https://github.com/acme/web.git" ] ) ,
80+ resolved : "remote.origin.gh-resolved base" ,
81+ } ;
82+ assert . strictEqual ( select ( input ) , null , url ) ;
83+ assert . deepStrictEqual (
84+ resolveGitHubRepository ( { ...input , hostHint : "github.com" , defaultHost : "github.com" } ) ,
85+ { host : "github.com" , locator : { host : "github.com" , owner : "acme" , name : "web" } } ,
86+ url ,
87+ ) ;
88+ }
89+ } ) ;
90+
5191 it ( "leaves gh to choose when it might weigh the remotes differently" , ( ) => {
5292 for ( const input of [
5393 { remotes : "" } ,
@@ -60,7 +100,7 @@ describe("selectGitHubBaseRepository", () => {
60100 [ "mirror" , "[email protected] :me/web.git" ] , 61101 ) ,
62102 } ,
63- { remotes : remotes ( [ "origin" , "git@github- work:me/web.git" ] ) } ,
103+ { remotes : remotes ( [ "origin" , "git@work:me/web.git" ] ) } ,
64104 {
65105 remotes : remotes (
66106 [ "origin" , "[email protected] :me/web.git" ] ,
0 commit comments