IJPL-165484: vcs marker: Add FUS for committing from the gutter

(cherry picked from commit 749ee08124716b36a172c2f0b125dcc384520533)

IJ-CR-149884

GitOrigin-RevId: ed11d2f3785005eae39d9113bcf4fca09176a268
This commit is contained in:
Aleksandr Krasilnikov
2024-11-06 17:14:32 +01:00
committed by intellij-monorepo-bot
parent 720ce629f0
commit 2d573a3486
3 changed files with 44 additions and 0 deletions

View File

@@ -348,6 +348,7 @@
<diff.DiffExtension implementation="com.intellij.vcs.commit.CommitSessionCollector$MyDiffExtension"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.vcs.commit.CommitSessionCounterUsagesCollector"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.openapi.vcs.ex.commit.CommitChunkCollector"/>
<advancedSetting id="vcs.annotations.preload" default="false" bundle="messages.VcsBundle" groupKey="advanced.settings.vcs"/>
<advancedSetting id="vcs.process.ignored" default="true" bundle="messages.VcsBundle" groupKey="advanced.settings.vcs"/>
@@ -368,6 +369,7 @@
<registryKey key="llm.vcs.shelve.title.generation"
description="Enables AI generated shelve change list title"
defaultValue="true"/>
</extensions>
<extensions defaultExtensionNs="org.jetbrains">

View File

@@ -0,0 +1,29 @@
// 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.openapi.vcs.ex.commit
import com.intellij.internal.statistic.eventLog.EventLogGroup
import com.intellij.internal.statistic.eventLog.events.EventFields
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector
internal object CommitChunkCollector : CounterUsagesCollector() {
private val group = EventLogGroup("vcs.commit.chunk", 1)
override fun getGroup(): EventLogGroup = group
private val IS_AMEND = EventFields.Boolean("amend")
private val CHUNK_LINES_COUNT = EventFields.RoundedInt("chunk_lines") // 0 - DELETED
private val MESSAGE_LINES_COUNT = EventFields.RoundedInt("message_lines")
private val MESSAGE_SUBJECT_LENGTH = EventFields.RoundedInt("message_subject_length")
private val COMMIT = group.registerVarargEvent("commit", IS_AMEND, CHUNK_LINES_COUNT, MESSAGE_LINES_COUNT, MESSAGE_SUBJECT_LENGTH)
fun logCommit(isAmend: Boolean, linesChanged: Int, messageLinesCount: Int, messageSubjectLength: Int) {
COMMIT.log(
IS_AMEND.with(isAmend),
CHUNK_LINES_COUNT.with(linesChanged),
MESSAGE_LINES_COUNT.with(messageLinesCount),
MESSAGE_SUBJECT_LENGTH.with(messageSubjectLength)
)
}
}

View File

@@ -208,6 +208,7 @@ private class CommitChunkPanel(private val tracker: ChangelistsLocalLineStatusTr
private class CommitChunkWorkflow(project: Project) : NonModalCommitWorkflow(project) {
lateinit var state: ChangeListCommitState
lateinit var range: LocalRange
init {
val vcses = ProjectLevelVcsManager.getInstance(project).allActiveVcss.toSet()
@@ -221,8 +222,19 @@ private class CommitChunkWorkflow(project: Project) : NonModalCommitWorkflow(pro
val committer = LocalChangesCommitter(project, state, commitContext)
addCommonResultHandlers(sessionInfo, committer)
committer.addResultHandler(ShowNotificationCommitResultHandler(committer))
logCommit()
committer.runCommit(VcsBundle.message("commit.changes"), false)
}
private fun logCommit() {
val message = state.commitMessage
val messageLines = message.lines().filter { it.isNotBlank() }
val subjectLength = messageLines.getOrNull(0)?.length ?: 0
val lines = range.line2 - range.line1
CommitChunkCollector.logCommit(commitContext.isAmendCommitMode, lines, messageLines.size, subjectLength)
}
}
private class CommitChunkWorkFlowHandler(
@@ -256,6 +268,7 @@ private class CommitChunkWorkFlowHandler(
override suspend fun updateWorkflow(sessionInfo: CommitSessionInfo): Boolean {
workflow.state = getCommitState()
workflow.range = rangeProvider()
return true
}