Added option to clone submodules when cloning a repo
This commit is contained in:
parent
8cfc3607c2
commit
552ac17d0e
@ -18,7 +18,7 @@ private const val TAG = "CloneRepositoryUseCase"
|
|||||||
class CloneRepositoryUseCase @Inject constructor(
|
class CloneRepositoryUseCase @Inject constructor(
|
||||||
private val handleTransportUseCase: HandleTransportUseCase,
|
private val handleTransportUseCase: HandleTransportUseCase,
|
||||||
) {
|
) {
|
||||||
operator fun invoke(directory: File, url: String): Flow<CloneStatus> = callbackFlow {
|
operator fun invoke(directory: File, url: String, cloneSubmodules: Boolean): Flow<CloneStatus> = callbackFlow {
|
||||||
var lastTitle: String = ""
|
var lastTitle: String = ""
|
||||||
var lastTotalWork = 0
|
var lastTotalWork = 0
|
||||||
var progress = 0
|
var progress = 0
|
||||||
@ -64,6 +64,7 @@ class CloneRepositoryUseCase @Inject constructor(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
.setTransportConfigCallback { handleTransportUseCase(it, null) }
|
.setTransportConfigCallback { handleTransportUseCase(it, null) }
|
||||||
|
.setCloneSubmodules(cloneSubmodules)
|
||||||
.call()
|
.call()
|
||||||
|
|
||||||
ensureActive()
|
ensureActive()
|
||||||
|
@ -2,6 +2,7 @@ package com.jetpackduba.gitnuro.ui.dialogs
|
|||||||
|
|
||||||
import androidx.compose.animation.animateContentSize
|
import androidx.compose.animation.animateContentSize
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
@ -18,6 +19,7 @@ import androidx.compose.ui.focus.focusRequester
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.jetpackduba.gitnuro.extensions.handMouseClickable
|
||||||
import com.jetpackduba.gitnuro.git.CloneStatus
|
import com.jetpackduba.gitnuro.git.CloneStatus
|
||||||
import com.jetpackduba.gitnuro.theme.outlinedTextFieldColors
|
import com.jetpackduba.gitnuro.theme.outlinedTextFieldColors
|
||||||
|
|
||||||
@ -85,6 +87,7 @@ private fun CloneInput(
|
|||||||
) {
|
) {
|
||||||
var url by remember { mutableStateOf(cloneViewModel.url) }
|
var url by remember { mutableStateOf(cloneViewModel.url) }
|
||||||
var directory by remember { mutableStateOf(cloneViewModel.directory) }
|
var directory by remember { mutableStateOf(cloneViewModel.directory) }
|
||||||
|
var cloneSubmodules by remember { mutableStateOf(true) }
|
||||||
|
|
||||||
val urlFocusRequester = remember { FocusRequester() }
|
val urlFocusRequester = remember { FocusRequester() }
|
||||||
val directoryFocusRequester = remember { FocusRequester() }
|
val directoryFocusRequester = remember { FocusRequester() }
|
||||||
@ -174,6 +177,34 @@ private fun CloneInput(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.handMouseClickable(
|
||||||
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
|
indication = null,
|
||||||
|
) {
|
||||||
|
cloneSubmodules = !cloneSubmodules
|
||||||
|
}
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 16.dp)
|
||||||
|
) {
|
||||||
|
Checkbox(
|
||||||
|
checked = cloneSubmodules,
|
||||||
|
onCheckedChange = {
|
||||||
|
cloneSubmodules = it
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(all = 8.dp)
|
||||||
|
.size(12.dp)
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
"Clone submodules recursively",
|
||||||
|
style = MaterialTheme.typography.body2,
|
||||||
|
color = MaterialTheme.colors.onBackground,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (errorMessage != null) {
|
if (errorMessage != null) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -213,7 +244,7 @@ private fun CloneInput(
|
|||||||
)
|
)
|
||||||
PrimaryButton(
|
PrimaryButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
cloneViewModel.clone(directory, url)
|
cloneViewModel.clone(directory, url, cloneSubmodules)
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.focusRequester(cloneButtonFocusRequester)
|
.focusRequester(cloneButtonFocusRequester)
|
||||||
|
@ -26,7 +26,7 @@ class CloneViewModel @Inject constructor(
|
|||||||
|
|
||||||
private var cloneJob: Job? = null
|
private var cloneJob: Job? = null
|
||||||
|
|
||||||
fun clone(directoryPath: String, url: String) {
|
fun clone(directoryPath: String, url: String, cloneSubmodules: Boolean) {
|
||||||
cloneJob = tabState.safeProcessingWithoutGit {
|
cloneJob = tabState.safeProcessingWithoutGit {
|
||||||
if (directoryPath.isBlank()) {
|
if (directoryPath.isBlank()) {
|
||||||
_cloneStatus.value = CloneStatus.Fail("Invalid empty directory")
|
_cloneStatus.value = CloneStatus.Fail("Invalid empty directory")
|
||||||
@ -69,7 +69,7 @@ class CloneViewModel @Inject constructor(
|
|||||||
repoDir.mkdir()
|
repoDir.mkdir()
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneRepositoryUseCase(repoDir, url)
|
cloneRepositoryUseCase(repoDir, url, cloneSubmodules)
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
.collect { newCloneStatus ->
|
.collect { newCloneStatus ->
|
||||||
_cloneStatus.value = newCloneStatus
|
_cloneStatus.value = newCloneStatus
|
||||||
|
@ -51,7 +51,7 @@ class BeforeRepoAllTestsExtension : BeforeAllCallback, AfterAllCallback {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
cloneRepositoryUseCase(repoDir, REPO_URL)
|
cloneRepositoryUseCase(repoDir, REPO_URL, false)
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
.collect { newCloneStatus ->
|
.collect { newCloneStatus ->
|
||||||
println("Cloning test repository: $newCloneStatus")
|
println("Cloning test repository: $newCloneStatus")
|
||||||
|
Loading…
Reference in New Issue
Block a user