Fixed crash when being detached from any branch

This commit is contained in:
Abdelilah El Aissaoui 2021-12-12 01:07:42 +01:00
parent 0fec32e25f
commit 05326f3a1d

View File

@ -1,5 +1,6 @@
package app.extensions
import org.eclipse.jgit.lib.Constants
import org.eclipse.jgit.lib.ObjectIdRef
import org.eclipse.jgit.lib.Ref
@ -8,24 +9,36 @@ private const val LOCAL_PREFIX_LENGTH = 2
val Ref.simpleName: String
get() {
return if (this.isRemote) {
return when {
this.name == Constants.HEAD -> {
this.name
}
this.isRemote -> {
val split = name.split("/")
split.takeLast(split.size - REMOTE_PREFIX_LENGTH).joinToString("/")
} else {
}
else -> {
val split = this.name.split("/")
split.takeLast(split.size - LOCAL_PREFIX_LENGTH).joinToString("/")
}
}
}
val Ref.simpleVisibleName: String
get() {
return if (this.isRemote) {
return when {
this.name == Constants.HEAD -> {
this.name
}
this.isRemote -> {
name.replace("refs/remotes/", "")
} else {
}
else -> {
val split = this.name.split("/")
split.takeLast(split.size - LOCAL_PREFIX_LENGTH).joinToString("/")
}
}
}
val Ref.isBranch: Boolean
get() {