Added remove tag functionality
This commit is contained in:
parent
2a43cdeca8
commit
efab5b0bfa
@ -12,13 +12,9 @@ import org.eclipse.jgit.lib.Repository
|
||||
import org.eclipse.jgit.revwalk.RevCommit
|
||||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
|
||||
import app.AppStateManager
|
||||
import app.app.Error
|
||||
import app.app.ErrorsManager
|
||||
import app.app.newErrorNow
|
||||
import app.extensions.dirPath
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import org.eclipse.jgit.lib.ObjectId
|
||||
import org.eclipse.jgit.treewalk.FileTreeIterator
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -233,6 +229,13 @@ class GitManager @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteTag(tag: Ref) = managerScope.launch {
|
||||
safeProcessing {
|
||||
tagsManager.deleteTag(safeGit, tag)
|
||||
refreshRepositoryInfo()
|
||||
}
|
||||
}
|
||||
|
||||
fun resetStaged(diffEntry: DiffEntry) = managerScope.launch {
|
||||
statusManager.reset(safeGit, diffEntry, staged = true)
|
||||
loadLog()
|
||||
|
@ -30,4 +30,11 @@ class TagsManager @Inject constructor() {
|
||||
.setObjectId(revCommit)
|
||||
.call()
|
||||
}
|
||||
|
||||
suspend fun deleteTag(git: Git, tag: Ref) = withContext(Dispatchers.IO) {
|
||||
git
|
||||
.tagDelete()
|
||||
.setTags(tag.name)
|
||||
.call()
|
||||
}
|
||||
}
|
@ -375,7 +375,8 @@ fun CommitLine(
|
||||
refs = commitRefs,
|
||||
onCheckoutRef = { ref -> gitManager.checkoutRef(ref) },
|
||||
onMergeBranch = { ref -> onMergeBranch(ref) },
|
||||
onDeleteBranch = { ref -> gitManager.deleteBranch(ref) }
|
||||
onDeleteBranch = { ref -> gitManager.deleteBranch(ref) },
|
||||
onDeleteTag = { ref -> gitManager.deleteTag(ref) },
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -391,6 +392,7 @@ fun CommitMessage(
|
||||
onCheckoutRef: (ref: Ref) -> Unit,
|
||||
onMergeBranch: (ref: Ref) -> Unit,
|
||||
onDeleteBranch: (ref: Ref) -> Unit,
|
||||
onDeleteTag: (ref: Ref) -> Unit,
|
||||
) {
|
||||
val textColor = if (selected) {
|
||||
MaterialTheme.colors.primary
|
||||
@ -415,9 +417,8 @@ fun CommitMessage(
|
||||
if (ref.isTag) {
|
||||
TagChip(
|
||||
ref = ref,
|
||||
onCheckoutTag = {
|
||||
onCheckoutRef(ref)
|
||||
}
|
||||
onCheckoutTag = { onCheckoutRef(ref) },
|
||||
onDeleteTag = { onDeleteTag(ref) },
|
||||
)
|
||||
} else if (ref.isBranch)
|
||||
BranchChip(
|
||||
@ -641,14 +642,28 @@ fun BranchChip(
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun TagChip(modifier: Modifier = Modifier, ref: Ref, onCheckoutTag: () -> Unit) {
|
||||
fun TagChip(
|
||||
modifier: Modifier = Modifier,
|
||||
ref: Ref,
|
||||
onCheckoutTag: () -> Unit,
|
||||
onDeleteTag: () -> Unit,
|
||||
) {
|
||||
val contextMenuItemsList = {
|
||||
listOf(
|
||||
mutableListOf(
|
||||
ContextMenuItem(
|
||||
label = "Checkout tag",
|
||||
onClick = onCheckoutTag
|
||||
)
|
||||
)
|
||||
).apply {
|
||||
if(ref.isLocal) {
|
||||
add(
|
||||
ContextMenuItem(
|
||||
label = "Delete tag",
|
||||
onClick = onDeleteTag
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefChip(
|
||||
|
Loading…
Reference in New Issue
Block a user