mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-11 20:05:25 +00:00
better error handling for git operations
This commit is contained in:
parent
6cd6d69817
commit
13b7b352bd
2 changed files with 21 additions and 6 deletions
|
|
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
- Added better error handling to git operations
|
||||
|
||||
## [3.1.3] - 2025-05-07
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -16,8 +16,12 @@ export const cloneRepository = async (cloneURL: string, path: string, onProgress
|
|||
await git.cwd({
|
||||
path,
|
||||
}).addConfig("remote.origin.fetch", "+refs/heads/*:refs/heads/*");
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to clone repository`);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(`Failed to clone repository: ${error.message}`);
|
||||
} else {
|
||||
throw new Error(`Failed to clone repository: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,8 +41,12 @@ export const fetchRepository = async (path: string, onProgress?: (event: SimpleG
|
|||
"--progress"
|
||||
]
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to fetch repository ${path}`);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(`Failed to fetch repository ${path}: ${error.message}`);
|
||||
} else {
|
||||
throw new Error(`Failed to fetch repository ${path}: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,8 +65,12 @@ export const upsertGitConfig = async (path: string, gitConfig: Record<string, st
|
|||
for (const [key, value] of Object.entries(gitConfig)) {
|
||||
await git.addConfig(key, value);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to set git config ${path}`);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(`Failed to set git config ${path}: ${error.message}`);
|
||||
} else {
|
||||
throw new Error(`Failed to set git config ${path}: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue