mirror of
https://github.com/go-gitea/gitea.git
synced 2025-12-18 19:11:36 +00:00
Add git.DIFF_RENAME_SIMILARITY_THRESHOLD option (#36164)
Make the threshold value passed to `git diff --find-renames` configurable
This commit is contained in:
@@ -5,6 +5,7 @@ package setting
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -17,20 +18,21 @@ var Git = struct {
|
||||
HomePath string
|
||||
DisableDiffHighlight bool
|
||||
|
||||
MaxGitDiffLines int
|
||||
MaxGitDiffLineCharacters int
|
||||
MaxGitDiffFiles int
|
||||
CommitsRangeSize int // CommitsRangeSize the default commits range size
|
||||
BranchesRangeSize int // BranchesRangeSize the default branches range size
|
||||
VerbosePush bool
|
||||
VerbosePushDelay time.Duration
|
||||
GCArgs []string `ini:"GC_ARGS" delim:" "`
|
||||
EnableAutoGitWireProtocol bool
|
||||
PullRequestPushMessage bool
|
||||
LargeObjectThreshold int64
|
||||
DisableCoreProtectNTFS bool
|
||||
DisablePartialClone bool
|
||||
Timeout struct {
|
||||
MaxGitDiffLines int
|
||||
MaxGitDiffLineCharacters int
|
||||
MaxGitDiffFiles int
|
||||
CommitsRangeSize int // CommitsRangeSize the default commits range size
|
||||
BranchesRangeSize int // BranchesRangeSize the default branches range size
|
||||
VerbosePush bool
|
||||
VerbosePushDelay time.Duration
|
||||
GCArgs []string `ini:"GC_ARGS" delim:" "`
|
||||
EnableAutoGitWireProtocol bool
|
||||
PullRequestPushMessage bool
|
||||
LargeObjectThreshold int64
|
||||
DisableCoreProtectNTFS bool
|
||||
DisablePartialClone bool
|
||||
DiffRenameSimilarityThreshold string
|
||||
Timeout struct {
|
||||
Default int
|
||||
Migrate int
|
||||
Mirror int
|
||||
@@ -39,19 +41,20 @@ var Git = struct {
|
||||
GC int `ini:"GC"`
|
||||
} `ini:"git.timeout"`
|
||||
}{
|
||||
DisableDiffHighlight: false,
|
||||
MaxGitDiffLines: 1000,
|
||||
MaxGitDiffLineCharacters: 5000,
|
||||
MaxGitDiffFiles: 100,
|
||||
CommitsRangeSize: 50,
|
||||
BranchesRangeSize: 20,
|
||||
VerbosePush: true,
|
||||
VerbosePushDelay: 5 * time.Second,
|
||||
GCArgs: []string{},
|
||||
EnableAutoGitWireProtocol: true,
|
||||
PullRequestPushMessage: true,
|
||||
LargeObjectThreshold: 1024 * 1024,
|
||||
DisablePartialClone: false,
|
||||
DisableDiffHighlight: false,
|
||||
MaxGitDiffLines: 1000,
|
||||
MaxGitDiffLineCharacters: 5000,
|
||||
MaxGitDiffFiles: 100,
|
||||
CommitsRangeSize: 50,
|
||||
BranchesRangeSize: 20,
|
||||
VerbosePush: true,
|
||||
VerbosePushDelay: 5 * time.Second,
|
||||
GCArgs: []string{},
|
||||
EnableAutoGitWireProtocol: true,
|
||||
PullRequestPushMessage: true,
|
||||
LargeObjectThreshold: 1024 * 1024,
|
||||
DisablePartialClone: false,
|
||||
DiffRenameSimilarityThreshold: "50%",
|
||||
Timeout: struct {
|
||||
Default int
|
||||
Migrate int
|
||||
@@ -117,4 +120,9 @@ func loadGitFrom(rootCfg ConfigProvider) {
|
||||
} else {
|
||||
Git.HomePath = filepath.Clean(Git.HomePath)
|
||||
}
|
||||
|
||||
// validate for a integer percentage between 0% and 100%
|
||||
if !regexp.MustCompile(`^([0-9]|[1-9][0-9]|100)%$`).MatchString(Git.DiffRenameSimilarityThreshold) {
|
||||
log.Fatal("Invalid git.DIFF_RENAME_SIMILARITY_THRESHOLD: %s", Git.DiffRenameSimilarityThreshold)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user