in src/main/kotlin/com/jetbrains/interactiveRebase/utils/gitUtils/IRGitRebaseUtils.kt [42:96]
override fun run(indicator: ProgressIndicator) {
val modelService = project.service<ModelService>()
val cherryCommands = commands.filterIsInstance<CherryCommand>()
var wasReordered = false
cherryCommands.forEachIndexed { index, command ->
val base = command.baseCommit
val newbie = command.commit
if (command.index != 0) {
wasReordered = true
}
GitCherryPicker(project).cherryPick(mutableListOf(base.commit))
try {
var head: GitCommit? = null
val consumer =
Consumer<GitCommit> {
commit ->
head = commit
}
GitHistoryUtils.loadDetails(project, repo?.root!!, consumer, "-n", "1")
var previousHead = modelService.branchInfo.initialCommits[0].commit
if (index != 0) {
previousHead = cherryCommands[index - 1].commit.commit
}
if (previousHead == head) {
var output = IRGitUtils(project).gitReset()
modelService.noMoreCherryPicking = true
project.service<ModelService>().removeAllChangesIfNeeded()
project.service<GraphService>().updateGraphInfo(project.service<ModelService>().graphInfo)
project.service<ActionService>().mainPanel.graphPanel.updateGraphPanel()
return
}
newbie.commit = head!!
project.service<RebaseInvoker>().commands.remove(command)
} catch (e: VcsException) {
}
}
modelService.noMoreCherryPicking = true
project.service<ModelService>().graphInfo.mainBranch.currentCommits.forEach { c ->
c.wasCherryPicked = false
c.changes.removeAll { it is CherryCommand }
}
project.service<ModelService>().graphInfo.addedBranch?.initialCommits?.forEach {
c ->
c.wasCherryPicked = false
}
project.service<ActionService>().mainPanel.graphPanel.updateGraphPanel()
if (project.service<RebaseInvoker>().commands.isNotEmpty() || wasReordered) {
project.service<RebaseInvoker>().executeCommands()
} else {
project.service<ModelService>().removeAllChangesIfNeeded()
project.service<ActionService>().mainPanel.graphPanel.updateGraphPanel()
project.service<ModelService>().fetchGraphInfo(0)
project.service<ModelService>().populateLocalBranches(0)
}
}