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.ObjectIdRef
|
||||||
import org.eclipse.jgit.lib.Ref
|
import org.eclipse.jgit.lib.Ref
|
||||||
|
|
||||||
|
private const val REMOTE_PREFIX_LENGTH = 3
|
||||||
|
private const val LOCAL_PREFIX_LENGTH = 2
|
||||||
|
|
||||||
val Ref.simpleName: String
|
val Ref.simpleName: String
|
||||||
get() {
|
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/", "")
|
name.replace("refs/remotes/", "")
|
||||||
else
|
} else {
|
||||||
this.name.split("/").last() // TODO Do not take the last one, just remove the prefixes
|
val split = this.name.split("/")
|
||||||
|
split.takeLast(split.size - LOCAL_PREFIX_LENGTH).joinToString("/")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val Ref.isBranch: Boolean
|
val Ref.isBranch: Boolean
|
||||||
|
@ -43,7 +43,6 @@ class BranchesManager @Inject constructor() {
|
|||||||
suspend fun getBranches(git: Git) = withContext(Dispatchers.IO) {
|
suspend fun getBranches(git: Git) = withContext(Dispatchers.IO) {
|
||||||
return@withContext git
|
return@withContext git
|
||||||
.branchList()
|
.branchList()
|
||||||
.setListMode(ListBranchCommand.ListMode.ALL)
|
|
||||||
.call()
|
.call()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +78,6 @@ class BranchesManager @Inject constructor() {
|
|||||||
.call()
|
.call()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
suspend fun deleteBranch(git: Git, branch: Ref) = withContext(Dispatchers.IO) {
|
suspend fun deleteBranch(git: Git, branch: Ref) = withContext(Dispatchers.IO) {
|
||||||
git
|
git
|
||||||
.branchDelete()
|
.branchDelete()
|
||||||
|
@ -738,7 +738,7 @@ fun RefChip(
|
|||||||
tint = MaterialTheme.colors.onPrimary,
|
tint = MaterialTheme.colors.onPrimary,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = ref.simpleName,
|
text = ref.simpleVisibleName,
|
||||||
color = MaterialTheme.colors.onPrimary,
|
color = MaterialTheme.colors.onPrimary,
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
Loading…
Reference in New Issue
Block a user