move unset to finally in fetch

This commit is contained in:
msukkari 2025-09-27 17:02:03 -07:00
parent 397c430c5a
commit 4f9cb6701f

View file

@ -78,10 +78,6 @@ export const fetchRepository = async (
"--prune",
"--progress"
]);
if (authHeader) {
await git.raw(["config", "--unset", "http.extraHeader", authHeader]);
}
} catch (error: unknown) {
const baseLog = `Failed to fetch repository: ${path}`;
if (env.SOURCEBOT_LOG_LEVEL !== "debug") {
@ -92,6 +88,16 @@ export const fetchRepository = async (
} else {
throw new Error(`${baseLog}. Error: ${error}`);
}
} finally {
if (authHeader) {
const git = simpleGit({
progress: onProgress,
}).cwd({
path: path,
})
await git.raw(["config", "--unset", "http.extraHeader", authHeader]);
}
}
}