MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / CreatePatch

Function CreatePatch

internal/diff/diff.go:16–20  ·  view source on GitHub ↗

CreatePatch computes a compact patch that transforms oldText into newText. The patch can be applied with ApplyPatch to recover newText from oldText.

(oldText, newText string)

Source from the content-addressed store, hash-verified

14// CreatePatch computes a compact patch that transforms oldText into newText.
15// The patch can be applied with ApplyPatch to recover newText from oldText.
16func CreatePatch(oldText, newText string) string {
17 diffs := dmp.DiffMain(oldText, newText, true)
18 patches := dmp.PatchMake(oldText, diffs)
19 return dmp.PatchToText(patches)
20}
21
22// ApplyPatch applies a patch to baseText to produce the target text.
23// Returns an error if the patch cannot be applied cleanly.

Callers 4

CreateReversePatchFunction · 0.85
TestCreateAndApplyPatchFunction · 0.85
TestIdenticalContentFunction · 0.85
TestIsDiffSmallerFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestCreateAndApplyPatchFunction · 0.68
TestIdenticalContentFunction · 0.68
TestIsDiffSmallerFunction · 0.68