MCPcopy Index your code
hub / github.com/coder/coder / formatDiff

Function formatDiff

scripts/develop/dbrecovery.go:424–452  ·  view source on GitHub ↗

formatDiff produces a simple line-based diff between two strings.

(labelA, labelB, a, b string)

Source from the content-addressed store, hash-verified

422
423// formatDiff produces a simple line-based diff between two strings.
424func formatDiff(labelA, labelB, a, b string) string {
425 linesA := strings.Split(a, "\n")
426 linesB := strings.Split(b, "\n")
427
428 var out strings.Builder
429 maxLines := len(linesA)
430 if len(linesB) > maxLines {
431 maxLines = len(linesB)
432 }
433
434 for i := 0; i < maxLines; i++ {
435 var lineA, lineB string
436 if i < len(linesA) {
437 lineA = linesA[i]
438 }
439 if i < len(linesB) {
440 lineB = linesB[i]
441 }
442 if lineA != lineB {
443 if lineA != "" {
444 _, _ = fmt.Fprintf(&out, " - (%s) %s\n", labelA, lineA)
445 }
446 if lineB != "" {
447 _, _ = fmt.Fprintf(&out, " + (%s) %s\n", labelB, lineB)
448 }
449 }
450 }
451 return out.String()
452}
453
454// updateMigrationTracking connects to the running server's
455// database and captures current migration state. Called after

Callers 1

checkAndRecoverFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected