Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: throw error if issue with git #16618

Merged
merged 14 commits into from
Jul 18, 2022
9 changes: 8 additions & 1 deletion lib/util/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,14 @@ export async function syncGit(): Promise<void> {
const durationMs = Math.round(Date.now() - cloneStart);
logger.debug({ durationMs }, 'git clone completed');
}
config.currentBranchSha = (await git.raw(['rev-parse', 'HEAD'])).trim();
try {
config.currentBranchSha = (await git.raw(['rev-parse', 'HEAD'])).trim();
} catch (err) /* istanbul ignore next */ {
if (err.message?.includes('fatal: not a git repository')) {
throw new Error(REPOSITORY_CHANGED);
}
throw err;
}
if (config.cloneSubmodules) {
const submodules = await getSubmodules();
for (const submodule of submodules) {
Expand Down