Skip to content

Commit f2975a9

Browse files
committed
fix: respository in MERGING state fix
1 parent 298ad21 commit f2975a9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/src/main/java/com/viscouspot/gitsync/util/GitManager.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import org.eclipse.jgit.lib.BatchingProgressMonitor
3737
import org.eclipse.jgit.lib.BranchTrackingStatus
3838
import org.eclipse.jgit.lib.Constants
3939
import org.eclipse.jgit.lib.ObjectId
40+
import org.eclipse.jgit.lib.RepositoryState
4041
import org.eclipse.jgit.lib.StoredConfig
4142
import org.eclipse.jgit.merge.ResolveMerger
4243
import org.eclipse.jgit.revwalk.RevSort
@@ -378,6 +379,14 @@ class GitManager(private val context: Context, private val activity: AppCompatAc
378379
logStatus(git)
379380
val trackingStatus = BranchTrackingStatus.of(git.repository, git.repository.branch)
380381
?: throw Exception(context.getString(R.string.auto_rebase_failed_exception))
382+
383+
if (git.repository.repositoryState == RepositoryState.MERGING || git.repository.repositoryState == RepositoryState.MERGING_RESOLVED) {
384+
log(LogType.PushToRepo, "Aborting previous merge to ensure clean state for rebase")
385+
git.rebase {
386+
setOperation(RebaseCommand.Operation.ABORT)
387+
}
388+
}
389+
381390
val rebaseResult = git.rebase {
382391
setUpstream(trackingStatus.remoteTrackingBranch)
383392
}

0 commit comments

Comments
 (0)