action.CommitView.SwitchToCommitDialog.text=Switch to Commit Dialog
action.Vcs.ToggleAmendCommitMode.text=Amend Commit
action.Vcs.ToggleAmendCommitMode.description=Modify the latest commit of the current branch
+action.Vcs.RunCommitChecks.text=Run Commit Checks
action.ChangesView.ShowCommitOptions.text=Show Commit Options
action.Vcs.ApplySelectedChanges.text=Cherry-Pick Selected Changes
action.Vcs.RevertSelectedChanges.text=Revert Selected Changes
<reference id="Vcs.MessageActionGroup"/>
</group>
+ <action id="Vcs.RunCommitChecks" class="com.intellij.vcs.commit.RunCommitChecksAction"/>
+
<action class="com.intellij.openapi.vcs.actions.VcsToolbarLabelAction" id="VcsToolbarLabelAction"/>
<group id="VcsToolbarActions">
<reference ref="Vcs.ToggleAmendCommitMode"/>
<reference ref="CheckinProject"/>
<reference ref="CheckinFiles"/>
+ <reference ref="Vcs.RunCommitChecks"/>
<reference ref="ChangesView.ShowCommitOptions"/>
<reference ref="UpdateFiles"/>
<reference ref="CheckStatusForFiles"/>
override fun vcsesChanged() {
initCommitHandlers()
- workflow.initCommitExecutors(getCommitExecutors(project, workflow.vcses))
+ workflow.initCommitExecutors(getCommitExecutors(project, workflow.vcses) + RunCommitChecksExecutor)
updateDefaultCommitActionEnabled()
updateDefaultCommitActionName()
coroutineScope.launch {
workflow.executeDefault {
- if (isSkipCommitChecks()) return@executeDefault ReturnResult.COMMIT
+ val isOnlyRunCommitChecks = commitContext.isOnlyRunCommitChecks
+ commitContext.isOnlyRunCommitChecks = false
+
+ if (isSkipCommitChecks() && !isOnlyRunCommitChecks) return@executeDefault ReturnResult.COMMIT
val indicator = IndeterminateIndicator(ui.commitProgressUi.startProgress())
indicator.addStateDelegate(object : AbstractProgressIndicatorExBase() {
override fun cancel() = this@launch.cancel()
})
try {
- runAllHandlers(executor, indicator)
+ runAllHandlers(executor, indicator, isOnlyRunCommitChecks)
}
finally {
indicator.stop()
return true
}
- private suspend fun runAllHandlers(executor: CommitExecutor?, indicator: ProgressIndicator): ReturnResult {
+ private suspend fun runAllHandlers(
+ executor: CommitExecutor?,
+ indicator: ProgressIndicator,
+ isOnlyRunCommitChecks: Boolean
+ ): ReturnResult {
workflow.runMetaHandlers(indicator)
FileDocumentManager.getInstance().saveAllDocuments()
if (handlersResult != ReturnResult.COMMIT) return handlersResult
val checksResult = runCommitChecks(indicator)
- if (checksResult != ReturnResult.COMMIT) isCommitChecksResultUpToDate = true
- return checksResult
+ if (checksResult != ReturnResult.COMMIT || isOnlyRunCommitChecks) isCommitChecksResultUpToDate = true
+
+ return if (isOnlyRunCommitChecks) ReturnResult.CANCEL else checksResult
}
private suspend fun runCommitChecks(indicator: ProgressIndicator): ReturnResult {
--- /dev/null
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package com.intellij.vcs.commit
+
+import com.intellij.idea.ActionsBundle
+import com.intellij.openapi.util.Key
+import com.intellij.openapi.util.NlsActions
+import com.intellij.openapi.vcs.changes.CommitContext
+import com.intellij.openapi.vcs.changes.CommitExecutor
+import com.intellij.openapi.vcs.changes.CommitSession
+import com.intellij.openapi.vcs.changes.actions.BaseCommitExecutorAction
+
+private val IS_ONLY_RUN_COMMIT_CHECKS_KEY = Key.create<Boolean>("Vcs.Commit.IsOnlyRunCommitChecks")
+internal var CommitContext.isOnlyRunCommitChecks: Boolean by commitProperty(IS_ONLY_RUN_COMMIT_CHECKS_KEY)
+
+internal object RunCommitChecksExecutor : CommitExecutor {
+ const val ID = "Vcs.RunCommitChecks.Executor"
+
+ override fun getId(): String = ID
+
+ override fun getActionText(): @NlsActions.ActionText String = ActionsBundle.message("action.Vcs.RunCommitChecks.text")
+ override fun useDefaultAction(): Boolean = false
+
+ override fun createCommitSession(commitContext: CommitContext): CommitSession {
+ commitContext.isOnlyRunCommitChecks = true
+ return CommitSession.VCS_COMMIT
+ }
+}
+
+internal class RunCommitChecksAction : BaseCommitExecutorAction() {
+ override val executorId: String get() = RunCommitChecksExecutor.ID
+}
\ No newline at end of file