mirror of https://github.com/kubernetes/kops.git
Merge pull request #8144 from zehuaiWANG/cleanup-buildDiffLines
clean up buildDiffLines
This commit is contained in:
commit
a90bee6a05
|
|
@ -82,8 +82,7 @@ func buildDiffLines(lString, rString string) []lineRecord {
|
||||||
// We do need to cleanup, as otherwise we get some spurious changes on complex diffs
|
// We do need to cleanup, as otherwise we get some spurious changes on complex diffs
|
||||||
diffs = dmp.DiffCleanupSemantic(diffs)
|
diffs = dmp.DiffCleanupSemantic(diffs)
|
||||||
|
|
||||||
l := ""
|
var l, r string
|
||||||
r := ""
|
|
||||||
|
|
||||||
var results []lineRecord
|
var results []lineRecord
|
||||||
for _, diff := range diffs {
|
for _, diff := range diffs {
|
||||||
|
|
@ -125,14 +124,14 @@ func buildDiffLines(lString, rString string) []lineRecord {
|
||||||
if len(lines) == 1 {
|
if len(lines) == 1 {
|
||||||
l += lines[0]
|
l += lines[0]
|
||||||
r += lines[0]
|
r += lines[0]
|
||||||
} else if len(lines) > 1 {
|
}
|
||||||
|
if len(lines) > 1 {
|
||||||
if l != "" || r != "" {
|
if l != "" || r != "" {
|
||||||
l += lines[0]
|
l += lines[0]
|
||||||
r += lines[0]
|
r += lines[0]
|
||||||
} else {
|
} else {
|
||||||
results = append(results, lineRecord{Type: diffmatchpatch.DiffEqual, Line: lines[0]})
|
results = append(results, lineRecord{Type: diffmatchpatch.DiffEqual, Line: lines[0]})
|
||||||
}
|
}
|
||||||
if len(lines) > 1 {
|
|
||||||
if r != "" {
|
if r != "" {
|
||||||
results = append(results, lineRecord{Type: diffmatchpatch.DiffInsert, Line: r})
|
results = append(results, lineRecord{Type: diffmatchpatch.DiffInsert, Line: r})
|
||||||
r = ""
|
r = ""
|
||||||
|
|
@ -142,7 +141,7 @@ func buildDiffLines(lString, rString string) []lineRecord {
|
||||||
results = append(results, lineRecord{Type: diffmatchpatch.DiffDelete, Line: l})
|
results = append(results, lineRecord{Type: diffmatchpatch.DiffDelete, Line: l})
|
||||||
l = ""
|
l = ""
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for i := 1; i < len(lines)-1; i++ {
|
for i := 1; i < len(lines)-1; i++ {
|
||||||
line := lines[i]
|
line := lines[i]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue