Added fetch all & after pull all the repository is reloaded
This commit is contained in:
parent
a3ff073b54
commit
1dca2dfd51
@ -13,6 +13,7 @@ import org.eclipse.jgit.transport.*
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
class RemoteOperationsManager @Inject constructor(
|
||||
private val sessionManager: GSessionManager
|
||||
) {
|
||||
@ -35,6 +36,25 @@ class RemoteOperationsManager @Inject constructor(
|
||||
.call()
|
||||
}
|
||||
|
||||
suspend fun fetchAll(git: Git) = withContext(Dispatchers.IO) {
|
||||
val remotes = git.remoteList().call()
|
||||
|
||||
for (remote in remotes) {
|
||||
git.fetch()
|
||||
.setRemote(remote.name)
|
||||
.setRefSpecs(remote.fetchRefSpecs)
|
||||
.setTransportConfigCallback {
|
||||
if (it is SshTransport) {
|
||||
it.sshSessionFactory = sessionManager.generateSshSessionFactory()
|
||||
} else if (it is HttpTransport) {
|
||||
it.credentialsProvider = HttpCredentialsProvider()
|
||||
}
|
||||
}
|
||||
.setCredentialsProvider(CredentialsProvider.getDefault())
|
||||
.call()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun push(git: Git, force: Boolean) = withContext(Dispatchers.IO) {
|
||||
val currentBranchRefSpec = git.repository.fullBranch
|
||||
|
||||
|
@ -58,6 +58,9 @@ fun Menu(
|
||||
extendedListItems = pullContextMenuItems(
|
||||
onPullRebase = {
|
||||
menuViewModel.pull(true)
|
||||
},
|
||||
onFetchAll = {
|
||||
menuViewModel.fetchAll()
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -5,11 +5,16 @@ import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
fun pullContextMenuItems(
|
||||
onPullRebase: () -> Unit,
|
||||
onFetchAll: () -> Unit,
|
||||
): List<DropDownContentData> {
|
||||
return mutableListOf(
|
||||
DropDownContentData(
|
||||
label = "Pull with rebase",
|
||||
onClick = onPullRebase,
|
||||
),
|
||||
DropDownContentData(
|
||||
label = "Fetch all",
|
||||
onClick = onFetchAll,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -15,7 +15,13 @@ class MenuViewModel @Inject constructor(
|
||||
fun pull(rebase: Boolean = false) = tabState.safeProcessing { git ->
|
||||
remoteOperationsManager.pull(git, rebase)
|
||||
|
||||
return@safeProcessing RefreshType.ONLY_LOG
|
||||
return@safeProcessing RefreshType.ALL_DATA
|
||||
}
|
||||
|
||||
fun fetchAll() = tabState.safeProcessing { git ->
|
||||
remoteOperationsManager.fetchAll(git)
|
||||
|
||||
return@safeProcessing RefreshType.ALL_DATA
|
||||
}
|
||||
|
||||
fun push(force: Boolean = false) = tabState.safeProcessing { git ->
|
||||
|
Loading…
Reference in New Issue
Block a user