@@ -5,6 +5,7 @@ package setting
55
66import (
77 "path/filepath"
8+ "regexp"
89 "strings"
910 "time"
1011
@@ -17,20 +18,21 @@ var Git = struct {
1718 HomePath string
1819 DisableDiffHighlight bool
1920
20- MaxGitDiffLines int
21- MaxGitDiffLineCharacters int
22- MaxGitDiffFiles int
23- CommitsRangeSize int // CommitsRangeSize the default commits range size
24- BranchesRangeSize int // BranchesRangeSize the default branches range size
25- VerbosePush bool
26- VerbosePushDelay time.Duration
27- GCArgs []string `ini:"GC_ARGS" delim:" "`
28- EnableAutoGitWireProtocol bool
29- PullRequestPushMessage bool
30- LargeObjectThreshold int64
31- DisableCoreProtectNTFS bool
32- DisablePartialClone bool
33- Timeout struct {
21+ MaxGitDiffLines int
22+ MaxGitDiffLineCharacters int
23+ MaxGitDiffFiles int
24+ CommitsRangeSize int // CommitsRangeSize the default commits range size
25+ BranchesRangeSize int // BranchesRangeSize the default branches range size
26+ VerbosePush bool
27+ VerbosePushDelay time.Duration
28+ GCArgs []string `ini:"GC_ARGS" delim:" "`
29+ EnableAutoGitWireProtocol bool
30+ PullRequestPushMessage bool
31+ LargeObjectThreshold int64
32+ DisableCoreProtectNTFS bool
33+ DisablePartialClone bool
34+ DiffRenameSimilarityThreshold string
35+ Timeout struct {
3436 Default int
3537 Migrate int
3638 Mirror int
@@ -39,19 +41,20 @@ var Git = struct {
3941 GC int `ini:"GC"`
4042 } `ini:"git.timeout"`
4143}{
42- DisableDiffHighlight : false ,
43- MaxGitDiffLines : 1000 ,
44- MaxGitDiffLineCharacters : 5000 ,
45- MaxGitDiffFiles : 100 ,
46- CommitsRangeSize : 50 ,
47- BranchesRangeSize : 20 ,
48- VerbosePush : true ,
49- VerbosePushDelay : 5 * time .Second ,
50- GCArgs : []string {},
51- EnableAutoGitWireProtocol : true ,
52- PullRequestPushMessage : true ,
53- LargeObjectThreshold : 1024 * 1024 ,
54- DisablePartialClone : false ,
44+ DisableDiffHighlight : false ,
45+ MaxGitDiffLines : 1000 ,
46+ MaxGitDiffLineCharacters : 5000 ,
47+ MaxGitDiffFiles : 100 ,
48+ CommitsRangeSize : 50 ,
49+ BranchesRangeSize : 20 ,
50+ VerbosePush : true ,
51+ VerbosePushDelay : 5 * time .Second ,
52+ GCArgs : []string {},
53+ EnableAutoGitWireProtocol : true ,
54+ PullRequestPushMessage : true ,
55+ LargeObjectThreshold : 1024 * 1024 ,
56+ DisablePartialClone : false ,
57+ DiffRenameSimilarityThreshold : "50%" ,
5558 Timeout : struct {
5659 Default int
5760 Migrate int
@@ -117,4 +120,9 @@ func loadGitFrom(rootCfg ConfigProvider) {
117120 } else {
118121 Git .HomePath = filepath .Clean (Git .HomePath )
119122 }
123+
124+ // validate for a integer percentage between 0% and 100%
125+ if ! regexp .MustCompile (`^([0-9]|[1-9][0-9]|100)%$` ).MatchString (Git .DiffRenameSimilarityThreshold ) {
126+ log .Fatal ("Invalid git.DIFF_RENAME_SIMILARITY_THRESHOLD: %s" , Git .DiffRenameSimilarityThreshold )
127+ }
120128}
0 commit comments