Fixed remote branch checkout
Also removed remote branches from "Branches" list in left menu (will add a future "remotes" list)
This commit is contained in:
parent
7a3d68e3a6
commit
a141b0676e
@ -3,12 +3,28 @@ package app.extensions
|
||||
import org.eclipse.jgit.lib.ObjectIdRef
|
||||
import org.eclipse.jgit.lib.Ref
|
||||
|
||||
private const val REMOTE_PREFIX_LENGTH = 3
|
||||
private const val LOCAL_PREFIX_LENGTH = 2
|
||||
|
||||
val Ref.simpleName: String
|
||||
get() {
|
||||
return if (this.isRemote)
|
||||
return if (this.isRemote) {
|
||||
val split = name.split("/")
|
||||
split.takeLast(split.size - REMOTE_PREFIX_LENGTH).joinToString("/")
|
||||
} else {
|
||||
val split = this.name.split("/")
|
||||
split.takeLast(split.size - LOCAL_PREFIX_LENGTH).joinToString("/")
|
||||
}
|
||||
}
|
||||
|
||||
val Ref.simpleVisibleName: String
|
||||
get() {
|
||||
return if (this.isRemote) {
|
||||
name.replace("refs/remotes/", "")
|
||||
else
|
||||
this.name.split("/").last() // TODO Do not take the last one, just remove the prefixes
|
||||
} else {
|
||||
val split = this.name.split("/")
|
||||
split.takeLast(split.size - LOCAL_PREFIX_LENGTH).joinToString("/")
|
||||
}
|
||||
}
|
||||
|
||||
val Ref.isBranch: Boolean
|
||||
|
@ -43,7 +43,6 @@ class BranchesManager @Inject constructor() {
|
||||
suspend fun getBranches(git: Git) = withContext(Dispatchers.IO) {
|
||||
return@withContext git
|
||||
.branchList()
|
||||
.setListMode(ListBranchCommand.ListMode.ALL)
|
||||
.call()
|
||||
}
|
||||
|
||||
@ -79,7 +78,6 @@ class BranchesManager @Inject constructor() {
|
||||
.call()
|
||||
}
|
||||
|
||||
|
||||
suspend fun deleteBranch(git: Git, branch: Ref) = withContext(Dispatchers.IO) {
|
||||
git
|
||||
.branchDelete()
|
||||
|
@ -738,7 +738,7 @@ fun RefChip(
|
||||
tint = MaterialTheme.colors.onPrimary,
|
||||
)
|
||||
Text(
|
||||
text = ref.simpleName,
|
||||
text = ref.simpleVisibleName,
|
||||
color = MaterialTheme.colors.onPrimary,
|
||||
fontSize = 12.sp,
|
||||
modifier = Modifier
|
||||
|
Loading…
Reference in New Issue
Block a user