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

Function removeGitSyncHook

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

Source from the content-addressed store, hash-verified

168 * the user's content untouched.
169 */
170export function removeGitSyncHook(
171 projectRoot: string,
172 hooks: GitHookName[] = DEFAULT_SYNC_HOOKS,
173): GitHookResult {
174 const hooksDir = gitHooksDir(projectRoot);
175 if (!hooksDir) {
176 return { installed: [], hooksDir: null, skipped: 'not a git repository' };
177 }
178
179 const removed: GitHookName[] = [];
180
181 for (const hook of hooks) {
182 const file = path.join(hooksDir, hook);
183 if (!fs.existsSync(file)) continue;
184
185 const original = fs.readFileSync(file, 'utf8');
186 if (!original.includes(MARKER_BEGIN)) continue;
187
188 const stripped = stripMarkerBlock(original);
189 if (isEffectivelyEmpty(stripped)) {
190 fs.unlinkSync(file);
191 } else {
192 fs.writeFileSync(file, `${stripped.replace(/\s*$/, '')}\n`);
193 chmodExecutable(file);
194 }
195 removed.push(hook);
196 }
197
198 return { installed: removed, hooksDir };
199}
200
201/** Whether any CodeGraph sync hook is currently installed. */
202export function isSyncHookInstalled(

Callers 2

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

Calls 5

gitHooksDirFunction · 0.85
stripMarkerBlockFunction · 0.85
isEffectivelyEmptyFunction · 0.85
chmodExecutableFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected