@@ -383,6 +383,62 @@ it.effect.each([
383383 } ) ,
384384) ;
385385
386+ it . effect . each ( [
387+ [ "a plain token" , "s3cret" ] ,
388+ [ "a token with an apostrophe" , "s3'cret" ] ,
389+ [ "a token with a double quote" , 's3"cret' ] ,
390+ [ "a host-only token with an at sign" , "abc@secret" ] ,
391+ [ "an unquoted token with an apostrophe" , "s3'cret" , true ] ,
392+ [ "an unquoted token with a double quote" , 's3"cret' , true ] ,
393+ [ "an unquoted URL with an apostrophe in its path" , "path-token" , true ] ,
394+ ] as const ) ( "keeps %s in the query out of a failed clone's error text" , ( [ , token , unquoted ] ) =>
395+ Effect . gen ( function * ( ) {
396+ const remote =
397+ token === "abc@secret"
398+ ? "https://github.com"
399+ : token === "path-token"
400+ ? "https://github.com/octocat/t3code's.git"
401+ : "https://github.com/octocat/t3code.git" ;
402+ const error = yield * Effect . flip (
403+ cloneInTemporaryDirectory (
404+ {
405+ execute : ( input ) =>
406+ Effect . gen ( function * ( ) {
407+ const cloneUrl = input . args . at ( - 2 ) ! ;
408+ // Git treats @ in a pathless URL's query as userinfo, losing the query delimiter.
409+ const diagnosticUrl =
410+ cloneUrl === "https://github.com?access_token=abc@secret"
411+ ? "https://secret"
412+ : cloneUrl ;
413+ yield * (
414+ input . progress ?. onStderrLine ?.(
415+ unquoted
416+ ? `fatal: ${ diagnosticUrl } /info/refs not valid: is this a git repository?`
417+ : `fatal: unable to access '${ diagnosticUrl } /': Could not resolve host: github.com` ,
418+ ) ?? Effect . void
419+ ) ;
420+ return yield * new GitCommandError ( {
421+ operation : input . operation ,
422+ command : "git" ,
423+ cwd : input . cwd ,
424+ detail : "Git command exited with a non-zero status." ,
425+ exitCode : 128 ,
426+ } ) ;
427+ } ) ,
428+ } ,
429+ { remoteUrl : `${ remote } ?access_token=${ token } ` } ,
430+ ) ,
431+ ) ;
432+
433+ assert . strictEqual (
434+ error . detail ,
435+ unquoted
436+ ? `fatal: ${ remote } not valid: is this a git repository?`
437+ : `fatal: unable to access '${ remote } ${ token === "abc@secret" ? "/" : "" } ': Could not resolve host: github.com` ,
438+ ) ;
439+ } ) ,
440+ ) ;
441+
386442it . effect ( "strips embedded credentials from the remote URL it reports" , ( ) =>
387443 Effect . gen ( function * ( ) {
388444 const fs = yield * FileSystem . FileSystem ;
0 commit comments