[orx-gui-archiver] Add logReferences and show to GitProvider, make GitProvider public

This commit is contained in:
Edwin Jakobs
2021-11-09 08:53:45 +01:00
parent 2c58b11f8d
commit bae1f071c4
3 changed files with 31 additions and 11 deletions

View File

@@ -25,6 +25,18 @@ class NativeGit : GitProvider {
override fun headReference(): String {
return listOf("git", "rev-parse", "--short", "HEAD").runCommand(dir)!!.first.trimEnd()
}
override fun logReferences(count: Int): List<String> {
val (out, err) = listOf("git", "log", "-$count", "--pretty=format:%h").runCommand(dir) ?: error("failed to get log references")
return out.split("\n").map { it.trim() }
}
override fun show(reference: String): String {
val (out, err) = listOf("git", "show", reference, "-U0").runCommand(dir) ?: error("failed to get diff")
return out
}
}
internal fun nativeGitInstalled(): Boolean {