Fixed fetch not working for newly added remotes
This commit is contained in:
parent
6d6cf3ffda
commit
a65b990a49
1 changed files with 8 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue