@@ -5,7 +5,7 @@ import { Connection, PrismaClient, Repo, RepoToConnection, RepoIndexingStatus, S
55import { GithubConnectionConfig , GitlabConnectionConfig , GiteaConnectionConfig } from '@sourcebot/schemas/v3/connection.type' ;
66import { AppContext , Settings , RepoMetadata } from "./types.js" ;
77import { getRepoPath , getTokenFromConfig , measure , getShardPrefix } from "./utils.js" ;
8- import { cloneRepository , fetchRepository } from "./git.js" ;
8+ import { cloneRepository , fetchRepository , upsertGitConfig } from "./git.js" ;
99import { existsSync , readdirSync , promises } from 'fs' ;
1010import { indexGitRepository } from "./zoekt.js" ;
1111import { PromClient } from './promClient.js' ;
@@ -240,7 +240,7 @@ export class RepoManager implements IRepoManager {
240240 }
241241 }
242242
243- const { durationMs } = await measure ( ( ) => cloneRepository ( cloneUrl . toString ( ) , repoPath , metadata . gitConfig , ( { method, stage, progress } ) => {
243+ const { durationMs } = await measure ( ( ) => cloneRepository ( cloneUrl . toString ( ) , repoPath , ( { method, stage, progress } ) => {
244244 this . logger . debug ( `git.${ method } ${ stage } stage ${ progress } % complete for ${ repo . id } ` )
245245 } ) ) ;
246246 cloneDuration_s = durationMs / 1000 ;
@@ -249,6 +249,13 @@ export class RepoManager implements IRepoManager {
249249 this . logger . info ( `Cloned ${ repo . id } in ${ cloneDuration_s } s` ) ;
250250 }
251251
252+ // Regardless of clone or fetch, always upsert the git config for the repo.
253+ // This ensures that the git config is always up to date for whatever we
254+ // have in the DB.
255+ if ( metadata . gitConfig ) {
256+ await upsertGitConfig ( repoPath , metadata . gitConfig ) ;
257+ }
258+
252259 this . logger . info ( `Indexing ${ repo . id } ...` ) ;
253260 const { durationMs } = await measure ( ( ) => indexGitRepository ( repo , this . settings , this . ctx ) ) ;
254261 const indexDuration_s = durationMs / 1000 ;
0 commit comments