Let package git depend on setting but not opposite (#15241)

* Let package git depend on setting but not opposite

* private some package variables
This commit is contained in:
Lunny Xiao 2021-06-26 19:28:55 +08:00 committed by GitHub
parent e673e42f7e
commit e3c626834b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 113 additions and 92 deletions

View file

@ -7,7 +7,6 @@ package setting
import (
"time"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
)
@ -19,8 +18,8 @@ var (
MaxGitDiffLines int
MaxGitDiffLineCharacters int
MaxGitDiffFiles int
CommitsRangeSize int
BranchesRangeSize 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:" "`
@ -54,7 +53,7 @@ var (
Pull int
GC int `ini:"GC"`
}{
Default: int(git.DefaultCommandExecutionTimeout / time.Second),
Default: 360,
Migrate: 600,
Mirror: 300,
Clone: 300,
@ -68,35 +67,4 @@ func newGit() {
if err := Cfg.Section("git").MapTo(&Git); err != nil {
log.Fatal("Failed to map Git settings: %v", err)
}
if err := git.SetExecutablePath(Git.Path); err != nil {
log.Fatal("Failed to initialize Git settings: %v", err)
}
git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second
version, err := git.LocalVersion()
if err != nil {
log.Fatal("Error retrieving git version: %v", err)
}
// force cleanup args
git.GlobalCommandArgs = []string{}
if git.CheckGitVersionAtLeast("2.9") == nil {
// Explicitly disable credential helper, otherwise Git credentials might leak
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
}
var format = "Git Version: %s"
var args = []interface{}{version.Original()}
// Since git wire protocol has been released from git v2.18
if Git.EnableAutoGitWireProtocol && git.CheckGitVersionAtLeast("2.18") == nil {
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "protocol.version=2")
format += ", Wire Protocol %s Enabled"
args = append(args, "Version 2") // for focus color
}
git.CommitsRangeSize = Git.CommitsRangeSize
git.BranchesRangeSize = Git.BranchesRangeSize
log.Info(format, args...)
}