@@ -5,7 +5,7 @@ import { detectAccountForRepo } from '@/utils/git';
55import { getSSHRemoteUrl , updateSSHConfig , addSSHKeyToAgent } from '@/utils/ssh' ;
66import { getAccount , getAccounts } from '@/lib/config' ;
77import { CloneOptions } from '@/types' ;
8- import { logError , logSuccess , logWarning , logInfo } from '@/utils/cli' ;
8+ import { logError , logSuccess , logWarning , logInfo , maskEmail } from '@/utils/cli' ;
99
1010/**
1111 * Clone a repository with the appropriate account
@@ -35,17 +35,46 @@ export async function cloneRepo(
3535 let selectedAccount ;
3636
3737 if ( detection . profile ) {
38- selectedProfile = detection . profile ;
39- selectedAccount = detection . account ;
40- logSuccess ( `Auto-detected account: ${ selectedProfile } ` ) ;
38+ logSuccess ( `Auto-detected account: ${ detection . profile } ` ) ;
39+
40+ const { confirmDetection } = await inquirer . prompt < { confirmDetection : boolean } > ( [
41+ {
42+ type : 'confirm' ,
43+ name : 'confirmDetection' ,
44+ message : `Use auto-detected account '${ detection . profile } '?` ,
45+ default : true ,
46+ } ,
47+ ] ) ;
48+
49+ if ( confirmDetection ) {
50+ selectedProfile = detection . profile ;
51+ selectedAccount = detection . account ;
52+ } else {
53+ // Show all available accounts for selection
54+ const allAccounts = Object . entries ( accounts ) ;
55+ const { profile } = await inquirer . prompt < { profile : string } > ( [
56+ {
57+ type : 'list' ,
58+ name : 'profile' ,
59+ message : 'Select account to use for this repository:' ,
60+ choices : allAccounts . map ( ( [ profileName , account ] ) => ( {
61+ name : `${ profileName } (${ account . name } )` ,
62+ value : profileName ,
63+ } ) ) ,
64+ } ,
65+ ] ) ;
66+
67+ selectedProfile = profile ;
68+ selectedAccount = getAccount ( profile ) ;
69+ }
4170 } else if ( detection . candidates && detection . candidates . length > 0 ) {
4271 const { profile } = await inquirer . prompt < { profile : string } > ( [
4372 {
4473 type : 'list' ,
4574 name : 'profile' ,
4675 message : 'Select account to use for this repository:' ,
4776 choices : detection . candidates . map ( ( [ profileName , account ] ) => ( {
48- name : `${ profileName } (${ account . name } - ${ account . email } )` ,
77+ name : `${ profileName } (${ account . name } )` ,
4978 value : profileName ,
5079 } ) ) ,
5180 } ,
@@ -103,7 +132,7 @@ export async function cloneRepo(
103132
104133 logSuccess ( `Git config set for account '${ selectedProfile } '` ) ;
105134 logInfo ( `Repository: ${ path . resolve ( targetDir ) } ` ) ;
106- logInfo ( `Account: ${ selectedAccount . name } <${ selectedAccount . email } >` ) ;
135+ logInfo ( `Account: ${ selectedAccount . name } <${ maskEmail ( selectedAccount . email ) } >` ) ;
107136
108137 if ( ! useSSH && url . startsWith ( 'https://' ) ) {
109138 logInfo ( "Note: Cloned with HTTPS. Use 'gitm use <profile>' to switch to SSH" ) ;
0 commit comments