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

Function stripMarkerBlocks

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

* Remove the marker blocks `owns` claims (and the blank line that follows * one), leaving every other block and all user content in place.

(content: string, owns: BlockOwner)

Source from the content-addressed store, hash-verified

172 * one), leaving every other block and all user content in place.
173 */
174function stripMarkerBlocks(content: string, owns: BlockOwner): string {
175 const lines = content.split('\n');
176 const kept: string[] = [];
177 for (let i = 0; i < lines.length; i++) {
178 if (lines[i]!.trim() !== MARKER_BEGIN) {
179 kept.push(lines[i]!);
180 continue;
181 }
182 let end = i;
183 while (end < lines.length && lines[end]!.trim() !== MARKER_END) end++;
184 const block = lines.slice(i, end + 1);
185 const rootLine = block.find((l) => l.trim().startsWith(ROOT_PREFIX));
186 const blockRoot = rootLine ? rootLine.trim().slice(ROOT_PREFIX.length) : null;
187 if (owns(blockRoot)) {
188 if (lines[end + 1]?.trim() === '') end++;
189 } else {
190 kept.push(...block);
191 }
192 i = end;
193 }
194 return kept.join('\n');
195}
196
197/** Whether a hook's shebang names a shell (a hook with none runs under sh). */
198function isShellHook(content: string): boolean {

Callers 2

installGitSyncHookFunction · 0.85
removeGitSyncHookFunction · 0.85

Calls 2

pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected