#3091 add config option for Git GC
This commit is contained in:
parent
15b0cbe318
commit
b0b88d9bc5
4 changed files with 29 additions and 24 deletions
|
@ -357,6 +357,7 @@ MIGRATE = 600
|
||||||
MIRROR = 300
|
MIRROR = 300
|
||||||
CLONE = 300
|
CLONE = 300
|
||||||
PULL = 300
|
PULL = 300
|
||||||
|
GC = 60
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
; Max number of items will response in a page
|
; Max number of items will response in a page
|
||||||
|
|
|
@ -1741,14 +1741,17 @@ func GitFsck() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitGcRepos() error {
|
func GitGcRepos() error {
|
||||||
args := append([]string{"gc"}, setting.Git.GcArgs...)
|
args := append([]string{"gc"}, setting.Git.GCArgs...)
|
||||||
return x.Where("id > 0").Iterate(new(Repository),
|
return x.Where("id > 0").Iterate(new(Repository),
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean interface{}) error {
|
||||||
repo := bean.(*Repository)
|
repo := bean.(*Repository)
|
||||||
if err := repo.GetOwner(); err != nil {
|
if err := repo.GetOwner(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, stderr, err := process.ExecDir(-1, RepoPath(repo.Owner.Name, repo.Name), "Repository garbage collection", "git", args...)
|
_, stderr, err := process.ExecDir(
|
||||||
|
time.Duration(setting.Git.Timeout.GC)*time.Second,
|
||||||
|
RepoPath(repo.Owner.Name, repo.Name), "Repository garbage collection",
|
||||||
|
"git", args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%v: %v", err, stderr)
|
return fmt.Errorf("%v: %v", err, stderr)
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -198,12 +198,13 @@ var (
|
||||||
MaxGitDiffLines int
|
MaxGitDiffLines int
|
||||||
MaxGitDiffLineCharacters int
|
MaxGitDiffLineCharacters int
|
||||||
MaxGitDiffFiles int
|
MaxGitDiffFiles int
|
||||||
GcArgs []string `delim:" "`
|
GCArgs []string `delim:" "`
|
||||||
Timeout struct {
|
Timeout struct {
|
||||||
Migrate int
|
Migrate int
|
||||||
Mirror int
|
Mirror int
|
||||||
Clone int
|
Clone int
|
||||||
Pull int
|
Pull int
|
||||||
|
GC int `ini:"GC"`
|
||||||
} `ini:"git.timeout"`
|
} `ini:"git.timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue