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

Function isShellHook

src/sync/git-hooks.ts:198–205  ·  view source on GitHub ↗

Whether a hook's shebang names a shell (a hook with none runs under sh).

(content: string)

Source from the content-addressed store, hash-verified

196
197/** Whether a hook's shebang names a shell (a hook with none runs under sh). */
198function isShellHook(content: string): boolean {
199 const first = content.split('\n', 1)[0]!.trim();
200 if (!first.startsWith('#!')) return true;
201 const words = first.slice(2).trim().split(/\s+/);
202 let program = path.posix.basename(words[0] ?? '');
203 if (program === 'env') program = path.posix.basename(words.slice(1).find((w) => !w.startsWith('-')) ?? '');
204 return SHELL_INTERPRETERS.has(program);
205}
206
207/** Whether a hook body is just a shebang / blank lines (i.e. only ever ours). */
208function isEffectivelyEmpty(content: string): boolean {

Callers 1

installGitSyncHookFunction · 0.85

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected