(
{
path,
keys,
onProgress,
signal,
}: {
path: string,
keys: string[],
onProgress?: onProgressFn,
signal?: AbortSignal
})
| 212 | * If a key is not set, this is a no-op. |
| 213 | */ |
| 214 | export const unsetGitConfig = async ( |
| 215 | { |
| 216 | path, |
| 217 | keys, |
| 218 | onProgress, |
| 219 | signal, |
| 220 | }: { |
| 221 | path: string, |
| 222 | keys: string[], |
| 223 | onProgress?: onProgressFn, |
| 224 | signal?: AbortSignal |
| 225 | }) => { |
| 226 | const git = createGitClientForPath(path, onProgress, signal); |
| 227 | |
| 228 | try { |
| 229 | const configList = await git.listConfig(); |
| 230 | const setKeys = Object.keys(configList.all); |
| 231 | |
| 232 | for (const key of keys) { |
| 233 | if (setKeys.includes(key)) { |
| 234 | await git.raw(['config', '--unset', key]); |
| 235 | } |
| 236 | } |
| 237 | } catch (error: unknown) { |
| 238 | if (error instanceof Error) { |
| 239 | throw new Error(`Failed to unset git config ${path}: ${error.message}`); |
| 240 | } else { |
| 241 | throw new Error(`Failed to unset git config ${path}: ${error}`); |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Returns true if `path` is the _root_ of a git repository. |
no test coverage detected