Added exception when pull has failed
This commit is contained in:
parent
9dc5296a61
commit
902626f04b
@ -8,6 +8,7 @@ import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.api.RebaseResult
|
||||
import org.eclipse.jgit.lib.ProgressMonitor
|
||||
import org.eclipse.jgit.lib.Ref
|
||||
import org.eclipse.jgit.transport.*
|
||||
@ -23,7 +24,7 @@ class RemoteOperationsManager @Inject constructor(
|
||||
get() = _cloneStatus
|
||||
|
||||
suspend fun pull(git: Git, rebase: Boolean) = withContext(Dispatchers.IO) {
|
||||
git
|
||||
val pullResult = git
|
||||
.pull()
|
||||
.setTransportConfigCallback {
|
||||
handleTransportCredentials(it)
|
||||
@ -31,6 +32,20 @@ class RemoteOperationsManager @Inject constructor(
|
||||
.setRebase(rebase)
|
||||
.setCredentialsProvider(CredentialsProvider.getDefault())
|
||||
.call()
|
||||
|
||||
if (!pullResult.isSuccessful) {
|
||||
var message = "Pull failed"
|
||||
|
||||
if(rebase) {
|
||||
message = when(pullResult.rebaseResult.status) {
|
||||
RebaseResult.Status.UNCOMMITTED_CHANGES -> "The pull with rebase has failed because you have got uncommited changes"
|
||||
RebaseResult.Status.CONFLICTS -> "Pull with rebase has conflicts, fix them to continue"
|
||||
else -> message
|
||||
}
|
||||
}
|
||||
|
||||
throw Exception(message)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun fetchAll(git: Git) = withContext(Dispatchers.IO) {
|
||||
|
Loading…
Reference in New Issue
Block a user