mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
refactor: Removed 'ai', just made it generate.
This commit is contained in:
parent
65798fcbb0
commit
3343a3a364
|
|
@ -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 (<c-o> then 'a').
|
||||
# Accessible via the commit menu (<c-o> then 'g').
|
||||
# Example: "claude -p 'Generate a conventional commit message for this diff:'"
|
||||
aiGenerateCommand: ""
|
||||
generateCommand: ""
|
||||
|
||||
# Config relating to merging
|
||||
merging:
|
||||
|
|
|
|||
|
|
@ -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 (<c-o> then 'a').
|
||||
// Accessible via the commit menu (<c-o> then 'g').
|
||||
// Example: "claude -p 'Generate a conventional commit message for this diff:'"
|
||||
AIGenerateCommand string `yaml:"aiGenerateCommand"`
|
||||
GenerateCommand string `yaml:"generateCommand"`
|
||||
}
|
||||
|
||||
type MergingConfig struct {
|
||||
|
|
|
|||
|
|
@ -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:]
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue