@@ -78,19 +78,17 @@ function pickMarkedRemote(
7878 remotes : ReadonlyMap < string , string > ,
7979 resolved : string ,
8080) : { readonly remoteName : string ; readonly remoteUrl : string } | null {
81- const marks : Array < { readonly remoteName : string ; readonly value : string } > = [ ] ;
82- for ( const line of resolved . split ( "\n" ) ) {
83- const separator = line . indexOf ( " " ) ;
84- const key = line . slice ( 0 , separator ) ;
85- const value = line . slice ( separator + 1 ) . trim ( ) ;
86- if ( separator === - 1 || ! key . startsWith ( "remote." ) || ! key . endsWith ( ".gh-resolved" ) ) continue ;
87- const remoteName = key . slice ( "remote." . length , - ".gh-resolved" . length ) ;
88- if ( remotes . has ( remoteName ) && value . length > 0 ) marks . push ( { remoteName, value } ) ;
89- }
81+ const marks = resolved . split ( "\n" ) . flatMap ( ( line ) => {
82+ const match = / ^ r e m o t e \. ( .+ ) \. g h - r e s o l v e d \s + ( \S + ) $ / u. exec ( line . trim ( ) ) ;
83+ const remoteUrl = match ?. [ 1 ] === undefined ? undefined : remotes . get ( match [ 1 ] ) ;
84+ return match ?. [ 1 ] && match [ 2 ] && remoteUrl
85+ ? [ { remoteName : match [ 1 ] , remoteUrl, value : match [ 2 ] } ]
86+ : [ ] ;
87+ } ) ;
9088 // gh's choice is ambiguous with several marks; GitHubSourceControlProvider ignores them too.
9189 const [ mark , ...others ] = marks ;
9290 if ( ! mark || others . length > 0 ) return null ;
93- const markedUrl = remotes . get ( mark . remoteName ) ! ;
91+ const markedUrl = mark . remoteUrl ;
9492 if ( mark . value === "base" ) return { remoteName : mark . remoteName , remoteUrl : markedUrl } ;
9593 const host = normalizeGitRemoteUrl ( markedUrl ) . split ( "/" ) [ 0 ] ;
9694 const markedKey = `${ host } /${ mark . value . toLowerCase ( ) } ` ;
0 commit comments