MCPcopy Index your code
hub / github.com/stackblitz/bolt.new / diffFiles

Function diffFiles

app/utils/diff.ts:61–76  ·  view source on GitHub ↗
(fileName: string, oldFileContent: string, newFileContent: string)

Source from the content-addressed store, hash-verified

59 * @see https://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html
60 */
61export function diffFiles(fileName: string, oldFileContent: string, newFileContent: string) {
62 let unifiedDiff = createTwoFilesPatch(fileName, fileName, oldFileContent, newFileContent);
63
64 const patchHeaderEnd = `--- ${fileName}\n+++ ${fileName}\n`;
65 const headerEndIndex = unifiedDiff.indexOf(patchHeaderEnd);
66
67 if (headerEndIndex >= 0) {
68 unifiedDiff = unifiedDiff.slice(headerEndIndex + patchHeaderEnd.length);
69 }
70
71 if (unifiedDiff === '') {
72 return undefined;
73 }
74
75 return unifiedDiff;
76}
77
78/**
79 * Converts the unified diff to HTML.

Callers 1

computeFileModificationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected