catch and rethrow simplegit exceptions

This commit is contained in:
msukkari 2025-03-01 20:53:33 -08:00
parent d33185c118
commit b27507eb7d

View file

@ -9,18 +9,22 @@ export const cloneRepository = async (cloneURL: string, path: string, gitConfig?
([key, value]) => ['--config', `${key}=${value}`] ([key, value]) => ['--config', `${key}=${value}`]
); );
await git.clone( try {
cloneURL, await git.clone(
path, cloneURL,
[ path,
"--bare", [
...configParams "--bare",
] ...configParams
); ]
);
await git.cwd({ await git.cwd({
path, path,
}).addConfig("remote.origin.fetch", "+refs/heads/*:refs/heads/*"); }).addConfig("remote.origin.fetch", "+refs/heads/*:refs/heads/*");
} catch (error) {
throw new Error(`Failed to clone repository`);
}
} }
@ -29,15 +33,19 @@ export const fetchRepository = async (path: string, onProgress?: (event: SimpleG
progress: onProgress, progress: onProgress,
}); });
await git.cwd({ try {
path: path, await git.cwd({
}).fetch( path: path,
"origin", }).fetch(
[ "origin",
"--prune", [
"--progress" "--prune",
] "--progress"
); ]
);
} catch (error) {
throw new Error(`Failed to fetch repository ${path}`);
}
} }
export const getBranches = async (path: string) => { export const getBranches = async (path: string) => {