MCPcopy Create free account
hub / github.com/sergi/go-diff / PatchMake

Method PatchMake

diffmatchpatch/patch.go:115–137  ·  view source on GitHub ↗

PatchMake computes a list of patches.

(opt ...interface{})

Source from the content-addressed store, hash-verified

113
114// PatchMake computes a list of patches.
115func (dmp *DiffMatchPatch) PatchMake(opt ...interface{}) []Patch {
116 if len(opt) == 1 {
117 diffs, _ := opt[0].([]Diff)
118 text1 := dmp.DiffText1(diffs)
119 return dmp.PatchMake(text1, diffs)
120 } else if len(opt) == 2 {
121 text1 := opt[0].(string)
122 switch t := opt[1].(type) {
123 case string:
124 diffs := dmp.DiffMain(text1, t, true)
125 if len(diffs) > 2 {
126 diffs = dmp.DiffCleanupSemantic(diffs)
127 diffs = dmp.DiffCleanupEfficiency(diffs)
128 }
129 return dmp.PatchMake(text1, diffs)
130 case []Diff:
131 return dmp.patchMake2(text1, t)
132 }
133 } else if len(opt) == 3 {
134 return dmp.PatchMake(opt[0], opt[2])
135 }
136 return []Patch{}
137}
138
139// patchMake2 computes a list of patches to turn text1 into text2.
140// text2 is not provided, diffs are the delta between text1 and text2.

Callers 5

TestPatchSplitMaxFunction · 0.80
TestPatchAddPaddingFunction · 0.80
TestPatchApplyFunction · 0.80

Calls 5

DiffText1Method · 0.95
DiffMainMethod · 0.95
DiffCleanupSemanticMethod · 0.95
DiffCleanupEfficiencyMethod · 0.95
patchMake2Method · 0.95

Tested by 5

TestPatchSplitMaxFunction · 0.64
TestPatchAddPaddingFunction · 0.64
TestPatchApplyFunction · 0.64