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,6 +9,7 @@ export const cloneRepository = async (cloneURL: string, path: string, gitConfig?
([key, value]) => ['--config', `${key}=${value}`]
);
try {
await git.clone(
cloneURL,
path,
@ -21,6 +22,9 @@ export const cloneRepository = async (cloneURL: string, path: string, gitConfig?
await git.cwd({
path,
}).addConfig("remote.origin.fetch", "+refs/heads/*:refs/heads/*");
} catch (error) {
throw new Error(`Failed to clone repository`);
}
}
@ -29,6 +33,7 @@ export const fetchRepository = async (path: string, onProgress?: (event: SimpleG
progress: onProgress,
});
try {
await git.cwd({
path: path,
}).fetch(
@ -38,6 +43,9 @@ export const fetchRepository = async (path: string, onProgress?: (event: SimpleG
"--progress"
]
);
} catch (error) {
throw new Error(`Failed to fetch repository ${path}`);
}
}
export const getBranches = async (path: string) => {