override fun editCommits()

in src/main/kotlin/git4ideaClasses/IREditorHandler.kt [40:70]


    override fun editCommits(file: File): Int {
        return try {
            if (myRebaseEditorShown) {
                val encoding = GitConfigUtil.getCommitEncoding(myProject, myRoot)
                val originalMessage = FileUtil.loadFile(file, encoding)
                val newMessage =
                    myRewordedCommitMessageProvider.getRewordedCommitMessage(myProject, myRoot, originalMessage)
                if (newMessage == null) {
                    myUnstructuredEditorCancelled = !handleUnstructuredEditor(file)
                    return if (myUnstructuredEditorCancelled) GitRebaseEditorHandler.ERROR_EXIT_CODE else 0
                }
                FileUtil.writeToFile(file, newMessage.toByteArray(Charset.forName(encoding)))
                0
            } else {
                setRebaseEditorShown()
                val success = handleInteractiveEditor(file)
                if (success) {
                    0
                } else {
                    myCommitListCancelled = true
                    GitRebaseEditorHandler.ERROR_EXIT_CODE
                }
            }
        } catch (e: VcsException) {
            LOG.error("Failed to load commit details for commits from git rebase file: $file", e)
            GitRebaseEditorHandler.ERROR_EXIT_CODE
        } catch (e: Exception) {
            LOG.error("Failed to edit git rebase file: $file", e)
            GitRebaseEditorHandler.ERROR_EXIT_CODE
        }
    }