(
{
path,
gitConfig,
onProgress,
signal,
}: {
path: string,
gitConfig: Record<string, string>,
onProgress?: onProgressFn,
signal?: AbortSignal
})
| 181 | * present in gitConfig. |
| 182 | */ |
| 183 | export const upsertGitConfig = async ( |
| 184 | { |
| 185 | path, |
| 186 | gitConfig, |
| 187 | onProgress, |
| 188 | signal, |
| 189 | }: { |
| 190 | path: string, |
| 191 | gitConfig: Record<string, string>, |
| 192 | onProgress?: onProgressFn, |
| 193 | signal?: AbortSignal |
| 194 | }) => { |
| 195 | const git = createGitClientForPath(path, onProgress, signal); |
| 196 | |
| 197 | try { |
| 198 | for (const [key, value] of Object.entries(gitConfig)) { |
| 199 | await git.addConfig(key, value); |
| 200 | } |
| 201 | } catch (error: unknown) { |
| 202 | if (error instanceof Error) { |
| 203 | throw new Error(`Failed to set git config ${path}: ${error.message}`); |
| 204 | } else { |
| 205 | throw new Error(`Failed to set git config ${path}: ${error}`); |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Unsets the specified keys in the git config for the repo at the given path. |
no test coverage detected