@@ -5,7 +5,7 @@ import { Connection, PrismaClient, Repo, RepoToConnection, RepoIndexingStatus, S
55import { GithubConnectionConfig , GitlabConnectionConfig , GiteaConnectionConfig , BitbucketConnectionConfig } from '@sourcebot/schemas/v3/connection.type' ;
66import { AppContext , Settings , repoMetadataSchema } from "./types.js" ;
77import { getRepoPath , getTokenFromConfig , measure , getShardPrefix } from "./utils.js" ;
8- import { cloneRepository , fetchRepository , upsertGitConfig } from "./git.js" ;
8+ import { cloneRepository , fetchRepository , unsetGitConfig , upsertGitConfig } from "./git.js" ;
99import { existsSync , readdirSync , promises } from 'fs' ;
1010import { indexGitRepository } from "./zoekt.js" ;
1111import { PromClient } from './promClient.js' ;
@@ -254,8 +254,15 @@ export class RepoManager implements IRepoManager {
254254 }
255255
256256 if ( existsSync ( repoPath ) && ! isReadOnly ) {
257- logger . info ( `Fetching ${ repo . displayName } ...` ) ;
257+ // @NOTE : in #483, we changed the cloning method s.t., we _no longer_
258+ // write the clone URL (which could contain a auth token) to the
259+ // `remote.origin.url` entry. For the upgrade scenario, we want
260+ // to unset this key since it is no longer needed, hence this line.
261+ // This will no-op if the key is already unset.
262+ // @see : https://github.com/sourcebot-dev/sourcebot/pull/483
263+ await unsetGitConfig ( repoPath , [ "remote.origin.url" ] ) ;
258264
265+ logger . info ( `Fetching ${ repo . displayName } ...` ) ;
259266 const { durationMs } = await measure ( ( ) => fetchRepository (
260267 remoteUrl ,
261268 repoPath ,
@@ -271,7 +278,6 @@ export class RepoManager implements IRepoManager {
271278 } else if ( ! isReadOnly ) {
272279 logger . info ( `Cloning ${ repo . displayName } ...` ) ;
273280
274- // Use the new secure cloning method that doesn't store credentials in .git/config
275281 const { durationMs } = await measure ( ( ) => cloneRepository (
276282 remoteUrl ,
277283 repoPath ,
0 commit comments