MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getPatchFromContents

Function getPatchFromContents

source code/utils/diff.ts:83–116  ·  view source on GitHub ↗
({
  filePath,
  oldContent,
  newContent,
  ignoreWhitespace = false,
  singleHunk = false,
}: {
  filePath: string
  oldContent: string
  newContent: string
  ignoreWhitespace?: boolean
  singleHunk?: boolean
})

Source from the content-addressed store, hash-verified

81}
82
83export function getPatchFromContents({
84 filePath,
85 oldContent,
86 newContent,
87 ignoreWhitespace = false,
88 singleHunk = false,
89}: {
90 filePath: string
91 oldContent: string
92 newContent: string
93 ignoreWhitespace?: boolean
94 singleHunk?: boolean
95}): StructuredPatchHunk[] {
96 const result = structuredPatch(
97 filePath,
98 filePath,
99 escapeForDiff(oldContent),
100 escapeForDiff(newContent),
101 undefined,
102 undefined,
103 {
104 ignoreWhitespace,
105 context: singleHunk ? 100_000 : CONTEXT_LINES,
106 timeout: DIFF_TIMEOUT_MS,
107 },
108 )
109 if (!result) {
110 return []
111 }
112 return result.hunks.map(_ => ({
113 ..._,
114 lines: _.lines.map(unescapeFromDiff),
115 }))
116}
117
118/**
119 * Get a patch for display with edits applied

Callers 2

getPatchForEditsFunction · 0.85
computeEditsFromContentsFunction · 0.85

Calls 1

escapeForDiffFunction · 0.85

Tested by

no test coverage detected