Skip to content

Commit bc80c7c

Browse files
committed
refactor: refactor commit prompts and update default OpenAI model
- 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]>
1 parent 9208dcb commit bc80c7c

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

cmd/commit.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,36 +291,30 @@ var commitCmd = &cobra.Command{
291291
return err
292292
}
293293

294+
// Handle preview: if preview and noConfirm, or preview prompt declined, then exit early
294295
if preview {
295296
if noConfirm {
296297
return nil
297-
} else {
298-
input := confirmation.New("Commit preview summary?", confirmation.Yes)
299-
ready, err := input.RunPrompt()
298+
}
299+
if ready, err := confirmation.New("Commit preview summary?", confirmation.Yes).RunPrompt(); err != nil || !ready {
300300
if err != nil {
301301
return err
302302
}
303-
if !ready {
304-
return nil
305-
}
303+
return nil
306304
}
307305
}
308306

307+
// Handle commit message change prompt when confirmation is enabled
309308
if !noConfirm {
310-
input := confirmation.New("Do you want to change the commit message?", confirmation.No)
311-
change, err := input.RunPrompt()
312-
if err != nil {
309+
if change, err := confirmation.New("Do you want to change the commit message?", confirmation.No).RunPrompt(); err != nil {
313310
return err
314-
}
315-
316-
if change {
311+
} else if change {
317312
m := initialPrompt(commitMessage)
318313
p := tea.NewProgram(m, tea.WithContext(cmd.Context()))
319314
if _, err := p.Run(); err != nil {
320315
return err
321316
}
322317
p.Wait()
323-
324318
commitMessage = m.textarea.Value()
325319
}
326320
}

cmd/config_set.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func init() {
1313
configCmd.AddCommand(configSetCmd)
1414
configSetCmd.Flags().StringP("base_url", "b", "", availableKeys["openai.base_url"])
1515
configSetCmd.Flags().StringP("api_key", "k", "", availableKeys["openai.api_key"])
16-
configSetCmd.Flags().StringP("model", "m", "gpt-3.5-turbo", availableKeys["openai.model"])
16+
configSetCmd.Flags().StringP("model", "m", "gpt-4o", availableKeys["openai.model"])
1717
configSetCmd.Flags().StringP("lang", "l", "en", availableKeys["openai.lang"])
1818
configSetCmd.Flags().StringP("org_id", "o", "", availableKeys["openai.org_id"])
1919
configSetCmd.Flags().StringP("proxy", "", "", availableKeys["openai.proxy"])

cmd/review.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func init() {
2323
"generate diffs with <n> lines of context, default is 3")
2424
reviewCmd.PersistentFlags().IntVar(&maxTokens, "max_tokens", 300,
2525
"the maximum number of tokens to generate in the chat completion.")
26-
reviewCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-3.5-turbo", "select openai model")
26+
reviewCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-4o", "select openai model")
2727
reviewCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "summarizing language uses English by default")
2828
reviewCmd.PersistentFlags().StringSliceVar(&excludeList, "exclude_list", []string{}, "exclude file from git diff command")
2929
reviewCmd.PersistentFlags().BoolVar(&commitAmend, "amend", false,

0 commit comments

Comments
 (0)