MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / finalizeFilePatchResponse

Function finalizeFilePatchResponse

projects/electron/src/modules/code/git.ts:1871–1892  ·  view source on GitHub ↗
(patch: string, allowTruncation: boolean = true)

Source from the content-addressed store, hash-verified

1869}
1870
1871function finalizeFilePatchResponse(patch: string, allowTruncation: boolean = true): GetFilePatchResponse {
1872 if (!patch) {
1873 return createEmptyFilePatchResponse()
1874 }
1875
1876 const truncated = allowTruncation && patch.length > MAX_PATCH_SIZE
1877 const patchStats = parsePatchStats(patch)
1878 const changedLines = patchStats.insertions + patchStats.deletions
1879 const hunkCount = countHunks(patch)
1880
1881 return {
1882 patch: truncated ? patch.slice(0, MAX_PATCH_SIZE) : patch,
1883 truncated,
1884 heavy: truncated || patch.length > 256 * 1024 || changedLines > 4_000 || hunkCount > 50,
1885 stats: {
1886 insertions: patchStats.insertions,
1887 deletions: patchStats.deletions,
1888 changedLines,
1889 hunkCount,
1890 },
1891 }
1892}
1893
1894async function getUntrackedFilePatch(
1895 workDir: string,

Callers 3

getUntrackedFilePatchFunction · 0.85
handleGetCommitFilePatchFunction · 0.85

Calls 3

parsePatchStatsFunction · 0.85
countHunksFunction · 0.85

Tested by

no test coverage detected