MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / unsetGitConfig

Function unsetGitConfig

packages/backend/src/git.ts:214–244  ·  view source on GitHub ↗
(
    {
        path,
        keys,
        onProgress,
        signal,
    }: {
        path: string,
        keys: string[],
        onProgress?: onProgressFn,
        signal?: AbortSignal
    })

Source from the content-addressed store, hash-verified

212 * If a key is not set, this is a no-op.
213 */
214export 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.

Callers 2

indexRepositoryMethod · 0.85
cloneRepositoryFunction · 0.85

Calls 1

createGitClientForPathFunction · 0.85

Tested by

no test coverage detected