MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / sanitizeUnifiedDiff

Function sanitizeUnifiedDiff

sdk/src/tools/apply-patch.ts:64–79  ·  view source on GitHub ↗
(rawDiff: string)

Source from the content-addressed store, hash-verified

62}
63
64function sanitizeUnifiedDiff(rawDiff: string): string {
65 const diffFenceMatch = rawDiff.match(/```diff\r?\n([\s\S]*?)\r?\n```/i)
66 if (diffFenceMatch) {
67 return diffFenceMatch[1]!
68 }
69
70 const trimmed = rawDiff.trim()
71 const fencedMatch = trimmed.match(
72 /^```(?:[a-zA-Z0-9_-]+)?\r?\n([\s\S]*?)\r?\n```$/,
73 )
74 if (fencedMatch) {
75 return fencedMatch[1]!
76 }
77
78 return rawDiff
79}
80
81function patchHasIntendedChanges(diff: string): boolean {
82 return normalizeLineEndings(diff)

Callers 1

applyPatchToolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected