From 14825ccb1fb4acd82421cd556d52822d464a3d72 Mon Sep 17 00:00:00 2001 From: Alexey Kryuchkov Date: Tue, 8 Aug 2023 17:16:30 +0300 Subject: [PATCH] Template for commit test GitOrigin-RevId: 0ed8d568d3e16286d6477ad359e049c32efc9cd1 --- .../performanceTesting/GitCommitCommand.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/git4idea/src/git4idea/performanceTesting/GitCommitCommand.kt b/plugins/git4idea/src/git4idea/performanceTesting/GitCommitCommand.kt index fdc813761b7a..5baf08103d65 100644 --- a/plugins/git4idea/src/git4idea/performanceTesting/GitCommitCommand.kt +++ b/plugins/git4idea/src/git4idea/performanceTesting/GitCommitCommand.kt @@ -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) }