diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index cf3c6906ba..9e93484f07 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -39,6 +39,7 @@ interface LocalConfig extends StorageConfig { baseBranchSha: string; branchExists: Record; branchPrefix: string; + syncCompleted: boolean; } // istanbul ignore next @@ -146,10 +147,11 @@ export async function getSubmodules(): Promise { .filter((_e: string, i: number) => i % 2); } -export async function initRepo(args: StorageConfig): Promise { - config = { ...args } as any; - - config.branchExists = {}; +export async function syncGit(): Promise { + if (config.syncCompleted) { + return; + } + config.syncCompleted = true; logger.debug('Initializing git repository into ' + config.localDir); const gitHead = join(config.localDir, '.git/HEAD'); let clone = true; @@ -232,6 +234,12 @@ export async function initRepo(args: StorageConfig): Promise { config.baseBranch = config.baseBranch || (await getDefaultBranch(git)); } +export async function initRepo(args: StorageConfig): Promise { + config = { ...args } as any; + config.branchExists = {}; + await syncGit(); +} + // istanbul ignore next export async function getRepoStatus(): Promise { return git.status();