diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/git/remote_operations/FetchAllBranchesUseCase.kt b/src/main/kotlin/com/jetpackduba/gitnuro/git/remote_operations/FetchAllBranchesUseCase.kt index ae73d6f..749de26 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/git/remote_operations/FetchAllBranchesUseCase.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/git/remote_operations/FetchAllBranchesUseCase.kt @@ -4,6 +4,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.eclipse.jgit.api.Git import org.eclipse.jgit.transport.CredentialsProvider +import org.eclipse.jgit.transport.RefSpec +import org.eclipse.jgit.transport.RemoteConfig import javax.inject.Inject class FetchAllBranchesUseCase @Inject constructor( @@ -13,9 +15,14 @@ class FetchAllBranchesUseCase @Inject constructor( val remotes = git.remoteList().call() for (remote in remotes) { + val refSpecs = remote.fetchRefSpecs.ifEmpty { + listOf(RefSpec("refs/heads/*:refs/remotes/${remote.name}/*")) + } + git.fetch() .setRemote(remote.name) - .setRefSpecs(remote.fetchRefSpecs) + .setRefSpecs(refSpecs) + .setRemoveDeletedRefs(true) .setTransportConfigCallback { handleTransportUseCase(it, git) } .setCredentialsProvider(CredentialsProvider.getDefault()) .call()