diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index 5facb30fd6502f7432d7c64f25af5a76574af806..b141f094506415a7508441659621941772a32376 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -433,7 +433,19 @@ export async function getFileList(): Promise<string[]> { await syncGit(); const branch = config.currentBranch; const submodules = await getSubmodules(); - const files: string = await git.raw(['ls-tree', '-r', branch]); + let files: string; + try { + files = await git.raw(['ls-tree', '-r', branch]); + } catch (err) /* istanbul ignore next */ { + if (err.message?.includes('fatal: Not a valid object name')) { + logger.debug( + { err }, + 'Branch not found when checking branch list - aborting' + ); + throw new Error(REPOSITORY_CHANGED); + } + throw err; + } // istanbul ignore if if (!files) { return [];