feat(config): add commitMessageGenerator config for external commit message generation

Add a new `git.commitMessageGenerator` configuration option that allows
users to specify a shell command to generate commit messages from staged
changes (e.g. using AI tools). The command should call `git diff
--cached` itself and output a commit message where the first line is
the title and the rest after a blank line is the body.

Also extract the "Generating commit message..." subtitle string into
the translation set for localization support, and update the JSON
schema to include the new configuration definition.
This commit is contained in:
sertdev 2026-02-18 13:26:28 +06:00
parent 4692f2c586
commit 1663d56ae3
4 changed files with 25 additions and 1 deletions

View File

@ -481,6 +481,13 @@ git:
# to 40 to disable truncation.
truncateCopiedCommitHashesTo: 12
# Config for external commit message generation (e.g. AI)
commitMessageGenerator:
# Shell command to generate a commit message from staged changes.
# The command should call `git diff --cached` itself and output a
# commit message (first line = title, rest after blank line = body).
command: ""
# Periodic update checks
update:
# One of: 'prompt' (default) | 'background' | 'never'

View File

@ -253,7 +253,7 @@ func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Sugg
func (self *CommitsHelper) generateCommitMessageAsync(command string) {
origSubtitle := self.c.Views().CommitDescription.Subtitle
self.c.Views().CommitDescription.Subtitle = "Generating commit message..."
self.c.Views().CommitDescription.Subtitle = self.c.Tr.GeneratingCommitMessage
// Snapshot current content so we can detect user edits
origSummary := self.getCommitSummary()

View File

@ -331,6 +331,7 @@ type TranslationSet struct {
CommitSummaryTitle string
CommitDescriptionTitle string
CommitDescriptionSubTitle string
GeneratingCommitMessage string
CommitDescriptionFooter string
CommitDescriptionFooterTwoBindings string
CommitHooksDisabledSubTitle string
@ -1434,6 +1435,7 @@ func EnglishTranslationSet() *TranslationSet {
CommitSummaryTitle: "Commit summary",
CommitDescriptionTitle: "Commit description",
CommitDescriptionSubTitle: "Press {{.togglePanelKeyBinding}} to toggle focus, {{.commitMenuKeybinding}} to open menu",
GeneratingCommitMessage: "Generating commit message...",
CommitDescriptionFooter: "Press {{.confirmInEditorKeybinding}} to submit",
CommitDescriptionFooterTwoBindings: "Press {{.confirmInEditorKeybinding1}} or {{.confirmInEditorKeybinding2}} to submit",
CommitHooksDisabledSubTitle: "(hooks disabled)",

View File

@ -37,6 +37,17 @@
"type": "object",
"description": "Config relating to the commit length indicator"
},
"CommitMessageGeneratorConfig": {
"properties": {
"command": {
"type": "string",
"description": "Shell command to generate a commit message from staged changes.\nThe command should call `git diff --cached` itself and output a\ncommit message (first line = title, rest after blank line = body)."
}
},
"additionalProperties": false,
"type": "object",
"description": "Config for external commit message generation (e.g. AI)"
},
"CommitPrefixConfig": {
"properties": {
"pattern": {
@ -446,6 +457,10 @@
"type": "integer",
"description": "When copying commit hashes to the clipboard, truncate them to this length. Set to 40 to disable truncation.",
"default": 12
},
"commitMessageGenerator": {
"$ref": "#/$defs/CommitMessageGeneratorConfig",
"description": "Config for external commit message generation (e.g. AI)"
}
},
"additionalProperties": false,