Added force push
This commit is contained in:
parent
c746f845ee
commit
171e9dc0be
@ -35,12 +35,13 @@ class RemoteOperationsManager @Inject constructor(
|
|||||||
.call()
|
.call()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun push(git: Git) = withContext(Dispatchers.IO) {
|
suspend fun push(git: Git, force: Boolean) = withContext(Dispatchers.IO) {
|
||||||
val currentBranchRefSpec = git.repository.fullBranch
|
val currentBranchRefSpec = git.repository.fullBranch
|
||||||
|
|
||||||
val pushResult = git
|
val pushResult = git
|
||||||
.push()
|
.push()
|
||||||
.setRefSpecs(RefSpec(currentBranchRefSpec))
|
.setRefSpecs(RefSpec(currentBranchRefSpec))
|
||||||
|
.setForce(force)
|
||||||
.setPushTags()
|
.setPushTags()
|
||||||
.setTransportConfigCallback {
|
.setTransportConfigCallback {
|
||||||
if (it is SshTransport) {
|
if (it is SshTransport) {
|
||||||
|
@ -24,6 +24,7 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import app.ui.context_menu.DropDownContent
|
import app.ui.context_menu.DropDownContent
|
||||||
import app.ui.context_menu.DropDownContentData
|
import app.ui.context_menu.DropDownContentData
|
||||||
|
import app.ui.context_menu.pushContextMenuItems
|
||||||
|
|
||||||
// TODO Add tooltips to all the buttons
|
// TODO Add tooltips to all the buttons
|
||||||
@Composable
|
@Composable
|
||||||
@ -60,10 +61,15 @@ fun Menu(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
MenuButton(
|
ExtendedMenuButton(
|
||||||
title = "Push",
|
title = "Push",
|
||||||
icon = painterResource("upload.svg"),
|
icon = painterResource("upload.svg"),
|
||||||
onClick = { menuViewModel.push() },
|
onClick = { menuViewModel.push() },
|
||||||
|
extendedListItems = pushContextMenuItems(
|
||||||
|
onForcePush = {
|
||||||
|
menuViewModel.push(true)
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.width(16.dp))
|
Spacer(modifier = Modifier.width(16.dp))
|
||||||
|
15
src/main/kotlin/app/ui/context_menu/PushContextMenu.kt
Normal file
15
src/main/kotlin/app/ui/context_menu/PushContextMenu.kt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package app.ui.context_menu
|
||||||
|
|
||||||
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
|
|
||||||
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
|
fun pushContextMenuItems(
|
||||||
|
onForcePush: () -> Unit,
|
||||||
|
): List<DropDownContentData> {
|
||||||
|
return mutableListOf(
|
||||||
|
DropDownContentData(
|
||||||
|
label = "Force push",
|
||||||
|
onClick = onForcePush,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
@ -18,8 +18,8 @@ class MenuViewModel @Inject constructor(
|
|||||||
return@safeProcessing RefreshType.ONLY_LOG
|
return@safeProcessing RefreshType.ONLY_LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
fun push() = tabState.safeProcessing { git ->
|
fun push(force: Boolean = false) = tabState.safeProcessing { git ->
|
||||||
remoteOperationsManager.push(git)
|
remoteOperationsManager.push(git, force)
|
||||||
|
|
||||||
return@safeProcessing RefreshType.ONLY_LOG
|
return@safeProcessing RefreshType.ONLY_LOG
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user