kotlin Multiplatform merge3 and diff utils
Go to file
2023-03-21 04:09:20 +01:00
gradle/wrapper initial commit: some diff algorithm 2023-03-21 03:34:46 +01:00
kotlin-js-store added mrged blocks and README.md 2023-03-21 04:09:20 +01:00
src added mrged blocks and README.md 2023-03-21 04:09:20 +01:00
.gitignore initial commit: some diff algorithm 2023-03-21 03:34:46 +01:00
build.gradle.kts added mrged blocks and README.md 2023-03-21 04:09:20 +01:00
gradle.properties initial commit: some diff algorithm 2023-03-21 03:34:46 +01:00
LICENSE.md initial commit: some diff algorithm 2023-03-21 03:34:46 +01:00
README.md added mrged blocks and README.md 2023-03-21 04:09:20 +01:00
settings.gradle.kts initial commit: some diff algorithm 2023-03-21 03:34:46 +01:00

3-way merge

Tho tools to make smart merge of two versions of changed original data. See [merge3] function online docs.

Usage

Add dependency:

repositories {
    //...
    maven("https://gitea.sergeych.net/api/packages/SergeychWorks/maven")
}

and in the source set dependencies something like

dependencies {
    // ...
    implementation("net.sergeych:mp_diff:0.0.1-SNAPSHOT")
}

Now call it in the code

val src = "Hello world".toList()
val a = "Hello friend".toList()
val b = "Bye world".toList()

val m = merge3(src, b, a)
assertEquals("Bye friend", m.merged.joinToString(""))
println(m.blocks)

Acknowledgments

This work is based on the original kotlin diff port https://github.com/GitLiveApp/kotlin-diff-utils work, unfortunatley its packaging is not compatible with current kotlin MP formats so I can't just use it as the dependencies. The wholde dev.gitlive.difflib is taken from the link above, where it was published under the Apache 2.0 license at the moment of borrowing this code.