MCPcopy Create free account
hub / github.com/arctic-cli/interface / filterPatch

Function filterPatch

packages/arctic/src/snapshot/index.ts:321–348  ·  view source on GitHub ↗
(patch: string, options: { exclude: Set<string> })

Source from the content-addressed store, hash-verified

319 }
320
321 export function filterPatch(patch: string, options: { exclude: Set<string> }): string {
322 if (!patch.trim()) return ""
323 const blocks: string[] = []
324 let current: string[] = []
325 let currentFile: string | undefined
326
327 const flush = () => {
328 if (!current.length) return
329 if (!currentFile || !options.exclude.has(currentFile)) {
330 blocks.push(current.join("\n"))
331 }
332 current = []
333 currentFile = undefined
334 }
335
336 for (const line of patch.split("\n")) {
337 if (line.startsWith("diff --git ")) {
338 flush()
339 current.push(line)
340 const match = line.match(/^diff --git a\/(.+?) b\/(.+)$/)
341 currentFile = match?.[2]
342 continue
343 }
344 current.push(line)
345 }
346 flush()
347 return blocks.join("\n").trim()
348 }
349
350 export const FileDiff = z
351 .object({

Callers

nothing calls this directly

Calls 2

pushMethod · 0.80
flushFunction · 0.70

Tested by

no test coverage detected