-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep track of changes of documents (halfway there) #6
Comments
Its actually easy: package main
import (
"fmt"
"github.com/sergi/go-diff/diffmatchpatch"
)
func diffRebuildtexts(diffs []diffmatchpatch.Diff) []string {
text := []string{"", ""}
for _, myDiff := range diffs {
if myDiff.Type != diffmatchpatch.DiffInsert {
text[0] += myDiff.Text
}
if myDiff.Type != diffmatchpatch.DiffDelete {
text[1] += myDiff.Text
}
}
return text
}
func main() {
dmp := diffmatchpatch.New()
a := "tiger"
b := "tigor"
diffs := dmp.DiffMain(a, b, true)
// Store as strings
delta := dmp.DiffToDelta(diffs)
fmt.Println(diffs)
text1 := dmp.DiffText1(diffs)
fmt.Println(text1, delta)
// rebuild from strings
seq1, _ := dmp.DiffFromDelta(text1, delta)
fmt.Println(seq1)
texts_linemode := diffRebuildtexts(seq1)
latest := texts_linemode[len(texts_linemode)-1]
fmt.Println(latest)
// add something else
newest := "tigre"
diffs = dmp.DiffMain(latest, newest, true)
// Store as strings
delta = dmp.DiffToDelta(diffs)
fmt.Println(diffs)
text1 = dmp.DiffText1(diffs)
fmt.Println(text1, delta)
// rebuild from strings
seq1, _ = dmp.DiffFromDelta(text1, delta)
fmt.Println(seq1)
texts_linemode = diffRebuildtexts(seq1)
latest = texts_linemode[len(texts_linemode)-1]
fmt.Println(latest)
} |
Its halfway there...got the diffs in there. Just need to make a client side way of accessing them. |
A subset of the diff documents should be shown to the user. Maybe all the documents that have a time between diffs of > 10 minutes? Or maybe a dynamic time setting that will allow fine/coarse adjustments. Or maybe just return the top 10 links to documents that have the greatest diffs between them. |
Done |
I guess this could be done by storing diffs, or by storing a git internally or something...
The text was updated successfully, but these errors were encountered: