Added SSH support for submodules

Fixes #109
This commit is contained in:
Abdelilah El Aissaoui 2023-05-09 18:41:50 +02:00
parent 905f7805bf
commit 181a1f8856
No known key found for this signature in database
GPG key ID: 7587FC860F594869

View file

@ -1,21 +1,24 @@
package com.jetpackduba.gitnuro.git.submodules
import com.jetpackduba.gitnuro.models.ProgressMonitorInfo
import com.jetpackduba.gitnuro.git.remote_operations.HandleTransportUseCase
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.ProgressMonitor
import org.eclipse.jgit.transport.CredentialsProvider
import javax.inject.Inject
class AddSubmoduleUseCase @Inject constructor() {
suspend operator fun invoke(git: Git, name: String, path: String, uri: String) = withContext(Dispatchers.IO) {
class AddSubmoduleUseCase @Inject constructor(
private val handleTransportUseCase: HandleTransportUseCase,
) {
suspend operator fun invoke(git: Git, name: String, path: String, uri: String): Unit = withContext(Dispatchers.IO) {
git.submoduleAdd()
.setName(name)
.setPath(path)
.setURI(uri)
.setTransportConfigCallback { handleTransportUseCase(it, git) }
.setCredentialsProvider(CredentialsProvider.getDefault())
.setProgressMonitor(object : ProgressMonitor {
override fun start(totalTasks: Int) {}
override fun beginTask(title: String?, totalWork: Int) {}