Skip to content

Commit

Permalink
refactor: refactor commit prompts and update default OpenAI model
Browse files Browse the repository at this point in the history
- Refactor commit preview confirmation prompt logic
- Refactor commit message change prompt logic
- Update default OpenAI model to `gpt-4o` in `config_set.go`
- Update default OpenAI model to `gpt-4o` in `review.go`

Signed-off-by: Bo-Yi Wu <[email protected]>
  • Loading branch information
appleboy committed Feb 13, 2025
1 parent 9208dcb commit bc80c7c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
20 changes: 7 additions & 13 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,36 +291,30 @@ var commitCmd = &cobra.Command{
return err
}

// Handle preview: if preview and noConfirm, or preview prompt declined, then exit early
if preview {
if noConfirm {
return nil
} else {
input := confirmation.New("Commit preview summary?", confirmation.Yes)
ready, err := input.RunPrompt()
}
if ready, err := confirmation.New("Commit preview summary?", confirmation.Yes).RunPrompt(); err != nil || !ready {
if err != nil {
return err
}
if !ready {
return nil
}
return nil
}
}

// Handle commit message change prompt when confirmation is enabled
if !noConfirm {
input := confirmation.New("Do you want to change the commit message?", confirmation.No)
change, err := input.RunPrompt()
if err != nil {
if change, err := confirmation.New("Do you want to change the commit message?", confirmation.No).RunPrompt(); err != nil {
return err
}

if change {
} else if change {
m := initialPrompt(commitMessage)
p := tea.NewProgram(m, tea.WithContext(cmd.Context()))
if _, err := p.Run(); err != nil {
return err
}
p.Wait()

commitMessage = m.textarea.Value()
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/config_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
configCmd.AddCommand(configSetCmd)
configSetCmd.Flags().StringP("base_url", "b", "", availableKeys["openai.base_url"])
configSetCmd.Flags().StringP("api_key", "k", "", availableKeys["openai.api_key"])
configSetCmd.Flags().StringP("model", "m", "gpt-3.5-turbo", availableKeys["openai.model"])
configSetCmd.Flags().StringP("model", "m", "gpt-4o", availableKeys["openai.model"])
configSetCmd.Flags().StringP("lang", "l", "en", availableKeys["openai.lang"])
configSetCmd.Flags().StringP("org_id", "o", "", availableKeys["openai.org_id"])
configSetCmd.Flags().StringP("proxy", "", "", availableKeys["openai.proxy"])
Expand Down
2 changes: 1 addition & 1 deletion cmd/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func init() {
"generate diffs with <n> lines of context, default is 3")
reviewCmd.PersistentFlags().IntVar(&maxTokens, "max_tokens", 300,
"the maximum number of tokens to generate in the chat completion.")
reviewCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-3.5-turbo", "select openai model")
reviewCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-4o", "select openai model")
reviewCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "summarizing language uses English by default")
reviewCmd.PersistentFlags().StringSliceVar(&excludeList, "exclude_list", []string{}, "exclude file from git diff command")
reviewCmd.PersistentFlags().BoolVar(&commitAmend, "amend", false,
Expand Down

0 comments on commit bc80c7c

Please sign in to comment.