-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
hepler.go
65 lines (50 loc) · 1.35 KB
/
hepler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package cmd
import (
"errors"
"github.com/appleboy/CodeGPT/openai"
"github.com/appleboy/CodeGPT/prompt"
"github.com/appleboy/CodeGPT/util"
"github.com/appleboy/com/file"
"github.com/spf13/viper"
)
func check() error {
// check git command exist
if !util.IsCommandAvailable("git") {
return errors.New("Git command not found on your system's PATH. Please install Git and try again.")
}
if diffUnified != 3 {
viper.Set("git.diff_unified", diffUnified)
}
if len(excludeList) > 0 {
viper.Set("git.exclude_list", excludeList)
}
// check default language
if prompt.GetLanguage(commitLang) != prompt.DefaultLanguage {
viper.Set("output.lang", commitLang)
}
// check default model
if openai.GetModel(commitModel) != openai.DefaultModel {
viper.Set("openai.model", commitModel)
}
if httpsProxy != "" {
viper.Set("openai.proxy", httpsProxy)
}
if socksProxy != "" {
viper.Set("openai.socks", socksProxy)
}
if maxTokens != 0 {
viper.Set("openai.max_tokens", maxTokens)
}
if templateFile != "" {
viper.Set("git.template_file", templateFile)
}
if templateString != "" {
viper.Set("git.template_string", templateString)
}
if viper.GetString("git.template_file") != "" {
if !file.IsFile(viper.GetString("git.template_file")) {
return errors.New("template file not found: " + viper.GetString("git.template_file"))
}
}
return nil
}