mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 15:06:56 +07:00
Template for commit test
GitOrigin-RevId: 0ed8d568d3e16286d6477ad359e049c32efc9cd1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1538c0e31c
commit
14825ccb1f
@@ -5,8 +5,8 @@ import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.vcs.FileStatus
|
||||
import com.intellij.openapi.vcs.LocalFilePath
|
||||
import com.intellij.openapi.vcs.changes.Change
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager
|
||||
import com.intellij.openapi.vcs.changes.CommitContext
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeListImpl
|
||||
import com.intellij.vcs.commit.ChangeListCommitState
|
||||
import com.intellij.vcs.commit.LocalChangesCommitter
|
||||
import com.jetbrains.performancePlugin.commands.PerformanceCommandCoroutineAdapter
|
||||
@@ -26,18 +26,19 @@ class GitCommitCommand(text: String, line: Int) : PerformanceCommandCoroutineAda
|
||||
|
||||
override suspend fun doExecute(context: PlaybackContext) {
|
||||
val (filePath, commitMessage) = extractCommandList(PREFIX, ",") ?: throw RuntimeException("Commit message wasn't passed")
|
||||
val localChangeList = LocalChangeListImpl.createEmptyChangeList(context.project, "")
|
||||
val localFilePath = ((context.project.guessProjectDir() ?: throw RuntimeException("Project dir is null")).findFileByRelativePath(filePath)
|
||||
?: throw RuntimeException("")).toNioPath()
|
||||
val changeList = ChangeListManager.getInstance(context.project).defaultChangeList
|
||||
|
||||
val projectDir = context.project.guessProjectDir() ?: throw RuntimeException("Project dir is null")
|
||||
val virtualFile = (projectDir.findFileByRelativePath(filePath) ?: throw RuntimeException("Specified file $filePath wasn't found")).toNioPath()
|
||||
|
||||
val beforeRevision = GitContentRevision.createRevision(
|
||||
LocalFilePath(localFilePath, false),
|
||||
LocalFilePath(virtualFile, false),
|
||||
GitRevisionNumber.HEAD,
|
||||
context.project,
|
||||
null
|
||||
context.project
|
||||
)
|
||||
|
||||
val change = Change(beforeRevision, beforeRevision, FileStatus.MODIFIED)
|
||||
val listCommitState = ChangeListCommitState(localChangeList, listOf(change), commitMessage)
|
||||
val listCommitState = ChangeListCommitState(changeList, listOf(change), commitMessage)
|
||||
LocalChangesCommitter(context.project, listCommitState, CommitContext()).runCommit("", true)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user