diff --git a/docs-master/Config.md b/docs-master/Config.md index cd47b85db..33c3c49d0 100644 --- a/docs-master/Config.md +++ b/docs-master/Config.md @@ -362,9 +362,9 @@ git: # Shell command that generates a commit message from a diff piped to stdin. # The command's stdout is used as the commit message (markdown fences are # stripped automatically). - # Accessible via the commit menu ( then 'a'). + # Accessible via the commit menu ( then 'g'). # Example: "claude -p 'Generate a conventional commit message for this diff:'" - aiGenerateCommand: "" + generateCommand: "" # Config relating to merging merging: diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index b5f3c5dec..520d32074 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -357,9 +357,9 @@ type CommitConfig struct { AutoWrapWidth int `yaml:"autoWrapWidth"` // Shell command that generates a commit message from a diff piped to stdin. // The command's stdout is used as the commit message (markdown fences are stripped automatically). - // Accessible via the commit menu ( then 'a'). + // Accessible via the commit menu ( then 'g'). // Example: "claude -p 'Generate a conventional commit message for this diff:'" - AIGenerateCommand string `yaml:"aiGenerateCommand"` + GenerateCommand string `yaml:"generateCommand"` } type MergingConfig struct { diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index bedbea83b..008246944 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -22,7 +22,7 @@ type CommitsHelper struct { getUnwrappedCommitDescription func() string setCommitDescription func(string) - // set to 1 while AI commit message generation is in progress + // set to 1 while commit message generation is in progress generating atomic.Int32 } @@ -207,10 +207,10 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S } } - var disabledReasonForAI *types.DisabledReason - if self.c.UserConfig().Git.Commit.AIGenerateCommand == "" { - disabledReasonForAI = &types.DisabledReason{ - Text: self.c.Tr.NoAICommandConfigured, + var disabledReasonForGenerate *types.DisabledReason + if self.c.UserConfig().Git.Commit.GenerateCommand == "" { + disabledReasonForGenerate = &types.DisabledReason{ + Text: self.c.Tr.NoGenerateCommandConfigured, } } @@ -238,12 +238,12 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S Key: 'p', }, { - Label: self.c.Tr.GenerateCommitMessageWithAI, + Label: self.c.Tr.GenerateCommitMessage, OnPress: func() error { - return self.generateCommitMessageWithAI() + return self.generateCommitMessage() }, - Key: 'a', - DisabledReason: disabledReasonForAI, + Key: 'g', + DisabledReason: disabledReasonForGenerate, }, } return self.c.Menu(types.CreateMenuOptions{ @@ -287,7 +287,7 @@ func (self *CommitsHelper) pasteCommitMessageFromClipboard() error { }) } -func (self *CommitsHelper) generateCommitMessageWithAI() error { +func (self *CommitsHelper) generateCommitMessage() error { self.generating.Store(1) self.c.Views().CommitMessage.Editable = false self.c.Views().CommitDescription.Editable = false @@ -313,21 +313,21 @@ func (self *CommitsHelper) generateCommitMessageWithAI() error { } if strings.TrimSpace(diff) == "" { self.c.OnUIThread(func() error { - self.c.ErrorToast(self.c.Tr.NoStagedChangesForAI) + self.c.ErrorToast(self.c.Tr.NoStagedChangesForGenerate) return nil }) return nil } - command := self.c.UserConfig().Git.Commit.AIGenerateCommand + command := self.c.UserConfig().Git.Commit.GenerateCommand message, err := self.c.OS().Cmd.NewShell(command, "").SetStdin(diff).DontLog().RunWithOutput() if err != nil { return err } - message = parseAIOutput(message) + message = parseGenerateOutput(message) if message == "" { - return errors.New("AI returned an empty commit message") + return errors.New("generate command returned an empty commit message") } self.c.OnUIThread(func() error { @@ -338,8 +338,8 @@ func (self *CommitsHelper) generateCommitMessageWithAI() error { }) } -// parseAIOutput strips markdown code fences and any preamble before them. -func parseAIOutput(s string) string { +// parseGenerateOutput strips markdown code fences and any preamble before them. +func parseGenerateOutput(s string) string { s = strings.TrimSpace(s) if start := strings.Index(s, "```"); start >= 0 { rest := s[start:] diff --git a/pkg/gui/controllers/helpers/commits_helper_test.go b/pkg/gui/controllers/helpers/commits_helper_test.go index 026f1d2ae..c8dacae41 100644 --- a/pkg/gui/controllers/helpers/commits_helper_test.go +++ b/pkg/gui/controllers/helpers/commits_helper_test.go @@ -45,7 +45,7 @@ func TestParseAIOutput(t *testing.T) { } for _, s := range scenarios { t.Run(s.name, func(t *testing.T) { - assert.Equal(t, s.expected, parseAIOutput(s.input)) + assert.Equal(t, s.expected, parseGenerateOutput(s.input)) }) } } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index ba7fcad88..753c816c0 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -672,10 +672,10 @@ type TranslationSet struct { CommitURL string PasteCommitMessageFromClipboard string SurePasteCommitMessage string - GenerateCommitMessageWithAI string + GenerateCommitMessage string GeneratingCommitMessageStatus string - NoStagedChangesForAI string - NoAICommandConfigured string + NoStagedChangesForGenerate string + NoGenerateCommandConfigured string CommitMessage string CommitMessageBody string CommitSubject string @@ -1793,10 +1793,10 @@ func EnglishTranslationSet() *TranslationSet { CommitURL: "Commit URL", PasteCommitMessageFromClipboard: "Paste commit message from clipboard", SurePasteCommitMessage: "Pasting will overwrite the current commit message, continue?", - GenerateCommitMessageWithAI: "Generate commit message with AI", + GenerateCommitMessage: "Generate commit message", GeneratingCommitMessageStatus: "Generating commit message...", - NoStagedChangesForAI: "No staged changes to generate a commit message from", - NoAICommandConfigured: "No AI command configured. Set git.commit.aiGenerateCommand in your config", + NoStagedChangesForGenerate: "No staged changes to generate a commit message from", + NoGenerateCommandConfigured: "No generate command configured. Set git.commit.generateCommand in your config", CommitMessage: "Commit message (subject and body)", CommitMessageBody: "Commit message body", CommitSubject: "Commit subject", diff --git a/schema-master/config.json b/schema-master/config.json index fb012bb3d..3fcd9899c 100644 --- a/schema-master/config.json +++ b/schema-master/config.json @@ -20,9 +20,9 @@ "description": "If autoWrapCommitMessage is true, the width to wrap to", "default": 72 }, - "aiGenerateCommand": { + "generateCommand": { "type": "string", - "description": "Shell command that generates a commit message from a diff piped to stdin.\nThe command's stdout is used as the commit message (markdown fences are stripped automatically).\nAccessible via the commit menu (\u003cc-o\u003e then 'a').\nExample: \"claude -p 'Generate a conventional commit message for this diff:'\"" + "description": "Shell command that generates a commit message from a diff piped to stdin.\nThe command's stdout is used as the commit message (markdown fences are stripped automatically).\nAccessible via the commit menu (\u003cc-o\u003e then 'g').\nExample: \"claude -p 'Generate a conventional commit message for this diff:'\"" } }, "additionalProperties": false,