MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / removeGitSyncHook

Function removeGitSyncHook

src/sync/git-hooks.ts:289–319  ·  view source on GitHub ↗
(
  projectRoot: string,
  hooks: GitHookName[] = DEFAULT_SYNC_HOOKS,
)

Source from the content-addressed store, hash-verified

287 * the user's content untouched.
288 */
289export function removeGitSyncHook(
290 projectRoot: string,
291 hooks: GitHookName[] = DEFAULT_SYNC_HOOKS,
292): GitHookResult {
293 const hooksDir = gitHooksDir(projectRoot);
294 if (!hooksDir) {
295 return { installed: [], hooksDir: null, skipped: 'not a git repository' };
296 }
297
298 const owns = ownerFor(projectRoot);
299 const removed: GitHookName[] = [];
300
301 for (const hook of hooks) {
302 const file = path.join(hooksDir, hook);
303 if (!fs.existsSync(file)) continue;
304
305 const original = fs.readFileSync(file, 'utf8');
306 if (!blockRoots(original).some(owns)) continue;
307
308 const stripped = stripMarkerBlocks(original, owns);
309 if (isEffectivelyEmpty(stripped)) {
310 fs.unlinkSync(file);
311 } else {
312 fs.writeFileSync(file, `${stripped.replace(/\s*$/, '')}\n`);
313 chmodExecutable(file);
314 }
315 removed.push(hook);
316 }
317
318 return { installed: removed, hooksDir };
319}
320
321/** Whether a CodeGraph sync hook is installed for this project root. */
322export function isSyncHookInstalled(

Callers 2

git-hooks.test.tsFile · 0.90
mainFunction · 0.85

Calls 8

gitHooksDirFunction · 0.85
ownerForFunction · 0.85
blockRootsFunction · 0.85
stripMarkerBlocksFunction · 0.85
isEffectivelyEmptyFunction · 0.85
chmodExecutableFunction · 0.85
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected