@@ -237,12 +237,32 @@ export class RepoManager implements IRepoManager {
237237 await promises . rm ( repoPath , { recursive : true , force : true } ) ;
238238 }
239239
240+ const credentials = await this . getCloneCredentialsForRepo ( repo , this . db ) ;
241+ const remoteUrl = new URL ( repo . cloneUrl ) ;
242+ if ( credentials ) {
243+ // @note : URL has a weird behavior where if you set the password but
244+ // _not_ the username, the ":" delimiter will still be present in the
245+ // URL (e.g., https://:password@example.com). To get around this, if
246+ // we only have a password, we set the username to the password.
247+ // @see : https://www.typescriptlang.org/play/?#code/MYewdgzgLgBArgJwDYwLwzAUwO4wKoBKAMgBQBEAFlFAA4QBcA9I5gB4CGAtjUpgHShOZADQBKANwAoREj412ECNhAIAJmhhl5i5WrJTQkELz5IQAcxIy+UEAGUoCAJZhLo0UA
248+ if ( ! credentials . username ) {
249+ remoteUrl . username = credentials . password ;
250+ } else {
251+ remoteUrl . username = credentials . username ;
252+ remoteUrl . password = credentials . password ;
253+ }
254+ }
255+
240256 if ( existsSync ( repoPath ) && ! isReadOnly ) {
241257 logger . info ( `Fetching ${ repo . displayName } ...` ) ;
242258
243- const { durationMs } = await measure ( ( ) => fetchRepository ( repoPath , ( { method, stage, progress } ) => {
244- logger . debug ( `git.${ method } ${ stage } stage ${ progress } % complete for ${ repo . displayName } ` )
245- } ) ) ;
259+ const { durationMs } = await measure ( ( ) => fetchRepository (
260+ remoteUrl ,
261+ repoPath ,
262+ ( { method, stage, progress } ) => {
263+ logger . debug ( `git.${ method } ${ stage } stage ${ progress } % complete for ${ repo . displayName } ` )
264+ }
265+ ) ) ;
246266 const fetchDuration_s = durationMs / 1000 ;
247267
248268 process . stdout . write ( '\n' ) ;
@@ -251,25 +271,14 @@ export class RepoManager implements IRepoManager {
251271 } else if ( ! isReadOnly ) {
252272 logger . info ( `Cloning ${ repo . displayName } ...` ) ;
253273
254- const auth = await this . getCloneCredentialsForRepo ( repo , this . db ) ;
255- const cloneUrl = new URL ( repo . cloneUrl ) ;
256- if ( auth ) {
257- // @note : URL has a weird behavior where if you set the password but
258- // _not_ the username, the ":" delimiter will still be present in the
259- // URL (e.g., https://:password@example.com). To get around this, if
260- // we only have a password, we set the username to the password.
261- // @see : https://www.typescriptlang.org/play/?#code/MYewdgzgLgBArgJwDYwLwzAUwO4wKoBKAMgBQBEAFlFAA4QBcA9I5gB4CGAtjUpgHShOZADQBKANwAoREj412ECNhAIAJmhhl5i5WrJTQkELz5IQAcxIy+UEAGUoCAJZhLo0UA
262- if ( ! auth . username ) {
263- cloneUrl . username = auth . password ;
264- } else {
265- cloneUrl . username = auth . username ;
266- cloneUrl . password = auth . password ;
274+ // Use the new secure cloning method that doesn't store credentials in .git/config
275+ const { durationMs } = await measure ( ( ) => cloneRepository (
276+ remoteUrl ,
277+ repoPath ,
278+ ( { method, stage, progress } ) => {
279+ logger . debug ( `git.${ method } ${ stage } stage ${ progress } % complete for ${ repo . displayName } ` )
267280 }
268- }
269-
270- const { durationMs } = await measure ( ( ) => cloneRepository ( cloneUrl . toString ( ) , repoPath , ( { method, stage, progress } ) => {
271- logger . debug ( `git.${ method } ${ stage } stage ${ progress } % complete for ${ repo . displayName } ` )
272- } ) ) ;
281+ ) ) ;
273282 const cloneDuration_s = durationMs / 1000 ;
274283
275284 process . stdout . write ( '\n' ) ;
@@ -540,7 +549,7 @@ export class RepoManager implements IRepoManager {
540549
541550 public async validateIndexedReposHaveShards ( ) {
542551 logger . info ( 'Validating indexed repos have shards...' ) ;
543-
552+
544553 const indexedRepos = await this . db . repo . findMany ( {
545554 where : {
546555 repoIndexingStatus : RepoIndexingStatus . INDEXED
@@ -556,7 +565,7 @@ export class RepoManager implements IRepoManager {
556565 const reposToReindex : number [ ] = [ ] ;
557566 for ( const repo of indexedRepos ) {
558567 const shardPrefix = getShardPrefix ( repo . orgId , repo . id ) ;
559-
568+
560569 // TODO: this doesn't take into account if a repo has multiple shards and only some of them are missing. To support that, this logic
561570 // would need to know how many total shards are expected for this repo
562571 let hasShards = false ;
0 commit comments