From ab8f5f5b3a5efc24eb8a6f8d0042b85c6254e753 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Mon, 5 Feb 2024 12:09:22 +0100 Subject: [PATCH] [lvcs] record a different name for the amend GitOrigin-RevId: 6f61814cb3562bc5e5a9ff568e4094fe07223470 --- .../resources/messages/VcsBundle.properties | 1 + .../com/intellij/vcs/commit/LocalChangesCommitter.kt | 12 ++++++++++-- .../git4idea/src/git4idea/index/GitStageCommitter.kt | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties b/platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties index 809c6ecf4387..34f88cfe265e 100644 --- a/platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties +++ b/platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties @@ -1255,6 +1255,7 @@ gutter.name.version.control.ignored.directories=Version control ignored director activity.name.commit=Commit changes activity.name.commit.message=Commit changes: {0} +activity.name.amend.message=Amend commit: {0} activity.name.update=Update from VCS activity.name.get=Get from VCS activity.name.get.from=Get from {0} diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/LocalChangesCommitter.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/LocalChangesCommitter.kt index 631d46bdaa76..f4107e7777df 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/LocalChangesCommitter.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/LocalChangesCommitter.kt @@ -1,10 +1,11 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.vcs.commit import com.intellij.history.LocalHistory import com.intellij.openapi.application.runReadAction import com.intellij.openapi.project.Project import com.intellij.openapi.util.Key +import com.intellij.openapi.util.NlsContexts import com.intellij.openapi.vcs.AbstractVcs import com.intellij.openapi.vcs.VcsBundle import com.intellij.openapi.vcs.VcsRoot @@ -13,6 +14,7 @@ import com.intellij.openapi.vcs.changes.ChangesUtil.processChangesByVcs import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache import com.intellij.openapi.vcs.update.RefreshVFsSynchronously import com.intellij.vcs.VcsActivity +import org.jetbrains.annotations.ApiStatus import org.jetbrains.annotations.Nls private val COMMIT_WITHOUT_CHANGES_ROOTS_KEY = Key.create>("Vcs.Commit.CommitWithoutChangesRoots") @@ -87,7 +89,7 @@ open class LocalChangesCommitter( VcsDirtyScopeManager.getInstance(project).filePathsDirty(pathsToRefresh, null) - LocalHistory.getInstance().putEventLabel(project, VcsBundle.message("activity.name.commit.message", commitMessage), VcsActivity.Commit) + LocalHistory.getInstance().putEventLabel(project, getLocalHistoryEventName(commitContext, commitMessage), VcsActivity.Commit) } finally { ChangeListManager.getInstance(project).invokeAfterUpdate(true) { fireAfterRefresh() } @@ -126,4 +128,10 @@ private class ChangeListDataCleaner(val committer: LocalChangesCommitter) : Comm changeListManager.editChangeListData(listName, null) } } +} + +@ApiStatus.Internal +fun getLocalHistoryEventName(commitContext: CommitContext, commitMessage: String): @NlsContexts.Label String { + if (commitContext.isAmendCommitMode) return VcsBundle.message("activity.name.amend.message", commitMessage) + return VcsBundle.message("activity.name.commit.message", commitMessage) } \ No newline at end of file diff --git a/plugins/git4idea/src/git4idea/index/GitStageCommitter.kt b/plugins/git4idea/src/git4idea/index/GitStageCommitter.kt index fd26ac036869..23a126ae42b3 100644 --- a/plugins/git4idea/src/git4idea/index/GitStageCommitter.kt +++ b/plugins/git4idea/src/git4idea/index/GitStageCommitter.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.index import com.intellij.history.LocalHistory @@ -13,6 +13,7 @@ import com.intellij.openapi.vfs.VirtualFile import com.intellij.vcs.VcsActivity import com.intellij.vcs.commit.AbstractCommitter import com.intellij.vcs.commit.commitWithoutChangesRoots +import com.intellij.vcs.commit.getLocalHistoryEventName import com.intellij.vcsUtil.VcsFileUtil import git4idea.GitUtil.getRepositoryForFile import git4idea.checkin.* @@ -65,7 +66,7 @@ internal class GitStageCommitter( } finally { refreshChanges() - LocalHistory.getInstance().putEventLabel(project, VcsBundle.message("activity.name.commit.message", commitMessage), VcsActivity.Commit) + LocalHistory.getInstance().putEventLabel(project, getLocalHistoryEventName(commitContext, commitMessage), VcsActivity.Commit) stagingAreaActionInvoked() } }