@@ -43,34 +43,34 @@ var (
43
43
)
44
44
45
45
func init () {
46
- commitCmd .PersistentFlags ().StringP ("file" , "f" , "" , "commit message file " )
47
- commitCmd .PersistentFlags ().BoolVar (& preview , "preview" , false , "preview commit message" )
46
+ commitCmd .PersistentFlags ().StringP ("file" , "f" , "" , "output file for commit message" )
47
+ commitCmd .PersistentFlags ().BoolVar (& preview , "preview" , false , "preview commit message before committing " )
48
48
commitCmd .PersistentFlags ().IntVar (& diffUnified , "diff_unified" , 3 ,
49
- "generate diffs with <n> lines of context, default is 3 " )
50
- commitCmd .PersistentFlags ().StringVar (& commitModel , "model" , "gpt-4o" , "select openai model" )
51
- commitCmd .PersistentFlags ().StringVar (& commitLang , "lang" , "en" , "summarizing language uses English by default" )
49
+ "generate diffs with <n> lines of context ( default: 3) " )
50
+ commitCmd .PersistentFlags ().StringVar (& commitModel , "model" , "gpt-4o" , "OpenAI model to use for generation " )
51
+ commitCmd .PersistentFlags ().StringVar (& commitLang , "lang" , "en" , "output language for the commit message ( default: English) " )
52
52
commitCmd .PersistentFlags ().StringSliceVar (& excludeList , "exclude_list" , []string {},
53
- "exclude file from git diff command " )
54
- commitCmd .PersistentFlags ().StringVar (& httpsProxy , "proxy" , "" , "http proxy" )
55
- commitCmd .PersistentFlags ().StringVar (& socksProxy , "socks" , "" , "socks proxy" )
56
- commitCmd .PersistentFlags ().StringVar (& templateFile , "template_file" , "" , "git commit message file " )
57
- commitCmd .PersistentFlags ().StringVar (& templateString , "template_string" , "" , "git commit message string " )
58
- commitCmd .PersistentFlags ().StringSliceVar (& templateVars , "template_vars" , []string {}, "template variables" )
59
- commitCmd .PersistentFlags ().StringVar (& templateVarsFile , "template_vars_file" , "" , "template variables file " )
53
+ "files to exclude from git diff" )
54
+ commitCmd .PersistentFlags ().StringVar (& httpsProxy , "proxy" , "" , "HTTP proxy URL " )
55
+ commitCmd .PersistentFlags ().StringVar (& socksProxy , "socks" , "" , "SOCKS proxy URL " )
56
+ commitCmd .PersistentFlags ().StringVar (& templateFile , "template_file" , "" , "template file for commit message format " )
57
+ commitCmd .PersistentFlags ().StringVar (& templateString , "template_string" , "" , "inline template string for commit message format " )
58
+ commitCmd .PersistentFlags ().StringSliceVar (& templateVars , "template_vars" , []string {}, "custom variables for templates " )
59
+ commitCmd .PersistentFlags ().StringVar (& templateVarsFile , "template_vars_file" , "" , "file containing template variables" )
60
60
commitCmd .PersistentFlags ().BoolVar (& commitAmend , "amend" , false ,
61
- "replace the tip of the current branch by creating a new commit. " )
62
- commitCmd .PersistentFlags ().DurationVarP (& timeout , "timeout" , "t" , defaultTimeout , "request timeout" )
61
+ "amend the previous commit instead of creating a new one " )
62
+ commitCmd .PersistentFlags ().DurationVarP (& timeout , "timeout" , "t" , defaultTimeout , "API request timeout duration " )
63
63
commitCmd .PersistentFlags ().BoolVar (& promptOnly , "prompt_only" , false ,
64
- "show prompt only, don't send request to openai " )
64
+ "display the prompt without sending to OpenAI " )
65
65
commitCmd .PersistentFlags ().BoolVar (& noConfirm , "no_confirm" , false ,
66
- "skip confirmation prompt " )
66
+ "skip all confirmation prompts " )
67
67
_ = viper .BindPFlag ("output.file" , commitCmd .PersistentFlags ().Lookup ("file" ))
68
68
}
69
69
70
70
// commitCmd represents the commit command.
71
71
var commitCmd = & cobra.Command {
72
72
Use : "commit" ,
73
- Short : "Auto generate commit message" ,
73
+ Short : "Automatically generate commit message" ,
74
74
RunE : func (cmd * cobra.Command , args []string ) error {
75
75
if err := check (); err != nil {
76
76
return err
@@ -92,25 +92,25 @@ var commitCmd = &cobra.Command{
92
92
viper .Set ("openai.timeout" , timeout )
93
93
}
94
94
95
- // check provider
95
+ // Check provider
96
96
provider := core .Platform (viper .GetString ("openai.provider" ))
97
97
client , err := GetClient (cmd .Context (), provider )
98
98
if err != nil && ! promptOnly {
99
99
return err
100
100
}
101
101
102
102
currentModel := viper .GetString ("openai.model" )
103
- color .Green ("Summarize the commit message use " + currentModel + " model" )
103
+ color .Green ("Summarizing commit message using " + currentModel + " model" )
104
104
105
105
data := util.Data {}
106
- // add template vars
106
+ // Add template variables
107
107
if vars := util .ConvertToMap (templateVars ); len (vars ) > 0 {
108
108
for k , v := range vars {
109
109
data [k ] = v
110
110
}
111
111
}
112
112
113
- // add template vars from file
113
+ // Add template variables from file
114
114
if templateVarsFile != "" {
115
115
allENV , err := godotenv .Read (templateVarsFile )
116
116
if err != nil {
@@ -121,7 +121,7 @@ var commitCmd = &cobra.Command{
121
121
}
122
122
}
123
123
124
- // Get code review message from diff datas
124
+ // Get code review message from diff data
125
125
if _ , ok := data [prompt .SummarizeMessageKey ]; ! ok {
126
126
out , err := util .GetTemplateByString (
127
127
prompt .SummarizeFileDiffTemplate ,
@@ -133,16 +133,16 @@ var commitCmd = &cobra.Command{
133
133
return err
134
134
}
135
135
136
- // determine if the user wants to use the prompt only
136
+ // Determine if the user wants to use the prompt only
137
137
if promptOnly {
138
138
color .Yellow ("====================Prompt========================" )
139
139
color .Yellow ("\n " + strings .TrimSpace (out ) + "\n \n " )
140
140
color .Yellow ("==================================================" )
141
141
return nil
142
142
}
143
143
144
- // Get summarize comment from diff datas
145
- color .Cyan ("We are trying to summarize a git diff" )
144
+ // Get summarized comment from diff data
145
+ color .Cyan ("Summarizing git diff... " )
146
146
resp , err := client .Completion (cmd .Context (), out )
147
147
if err != nil {
148
148
return err
@@ -151,7 +151,7 @@ var commitCmd = &cobra.Command{
151
151
color .Magenta (resp .Usage .String ())
152
152
}
153
153
154
- // Get summarize title from diff datas
154
+ // Get summarized title from diff data
155
155
if _ , ok := data [prompt .SummarizeTitleKey ]; ! ok {
156
156
out , err := util .GetTemplateByString (
157
157
prompt .SummarizeTitleTemplate ,
@@ -163,16 +163,16 @@ var commitCmd = &cobra.Command{
163
163
return err
164
164
}
165
165
166
- // Get summarize title from diff datas
167
- color .Cyan ("We are trying to summarize a title for pull request" )
166
+ // Generate title for pull request
167
+ color .Cyan ("Generating title for pull request... " )
168
168
resp , err := client .Completion (cmd .Context (), out )
169
169
if err != nil {
170
170
return err
171
171
}
172
172
summarizeTitle := resp .Content
173
173
color .Magenta (resp .Usage .String ())
174
174
175
- // lowercase the first character of first word of the commit message and remove last period
175
+ // Lowercase the first character of first word of the commit message and remove the trailing period
176
176
summarizeTitle = strings .TrimRight (strings .ToLower (string (summarizeTitle [0 ]))+ summarizeTitle [1 :], "." )
177
177
data [prompt .SummarizeTitleKey ] = strings .TrimSpace (summarizeTitle )
178
178
}
@@ -187,7 +187,7 @@ var commitCmd = &cobra.Command{
187
187
if err != nil {
188
188
return err
189
189
}
190
- message := "We are trying to get conventional commit prefix"
190
+ message := "Generating conventional commit prefix"
191
191
summaryPrix := ""
192
192
color .Cyan (message + " (Tools)" )
193
193
resp , err := client .GetSummaryPrefix (cmd .Context (), out )
@@ -244,8 +244,8 @@ var commitCmd = &cobra.Command{
244
244
return err
245
245
}
246
246
247
- // translate a git commit message
248
- color .Cyan ("We are trying to translate a git commit message to " + prompt .GetLanguage (viper .GetString ("output.lang" )) + " language" )
247
+ // Translate git commit message
248
+ color .Cyan ("Translating git commit message to " + prompt .GetLanguage (viper .GetString ("output.lang" )))
249
249
resp , err := client .Completion (cmd .Context (), out )
250
250
if err != nil {
251
251
return err
@@ -254,7 +254,7 @@ var commitCmd = &cobra.Command{
254
254
commitMessage = resp .Content
255
255
}
256
256
257
- // unescape html entities in commit message
257
+ // Unescape HTML entities in commit message
258
258
commitMessage = html .UnescapeString (commitMessage )
259
259
commitMessage = strings .TrimSpace (commitMessage )
260
260
@@ -271,8 +271,8 @@ var commitCmd = &cobra.Command{
271
271
}
272
272
outputFile = path .Join (strings .TrimSpace (out ), "COMMIT_EDITMSG" )
273
273
}
274
- color .Cyan ("Write the commit message to " + outputFile + " file" )
275
- // write commit message to git staging file
274
+ color .Cyan ("Writing commit message to " + outputFile )
275
+ // Write commit message to git staging file
276
276
err = os .WriteFile (outputFile , []byte (commitMessage ), 0o600 )
277
277
if err != nil {
278
278
return err
@@ -283,7 +283,7 @@ var commitCmd = &cobra.Command{
283
283
if noConfirm {
284
284
return nil
285
285
}
286
- if ready , err := confirmation .New ("Commit preview summary?" , confirmation .Yes ).RunPrompt (); err != nil || ! ready {
286
+ if ready , err := confirmation .New ("Commit this preview summary?" , confirmation .Yes ).RunPrompt (); err != nil || ! ready {
287
287
if err != nil {
288
288
return err
289
289
}
@@ -293,7 +293,7 @@ var commitCmd = &cobra.Command{
293
293
294
294
// Handle commit message change prompt when confirmation is enabled
295
295
if ! noConfirm {
296
- if change , err := confirmation .New ("Do you want to change the commit message?" , confirmation .No ).RunPrompt (); err != nil {
296
+ if change , err := confirmation .New ("Do you want to modify the commit message?" , confirmation .No ).RunPrompt (); err != nil {
297
297
return err
298
298
} else if change {
299
299
m := initialPrompt (commitMessage )
@@ -306,8 +306,8 @@ var commitCmd = &cobra.Command{
306
306
}
307
307
}
308
308
309
- // git commit automatically
310
- color .Cyan ("Git record changes to the repository" )
309
+ // Commit changes to repository
310
+ color .Cyan ("Recording changes to the repository" )
311
311
output , err := g .Commit (commitMessage )
312
312
if err != nil {
313
313
return err
0 commit comments