mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-25 09:40:56 +08:00
Allow setting git operations timeouts
- Migrate: #2704 #2653 - Clone: #2701 - Mirror, Pull
This commit is contained in:
parent
ea80274229
commit
9e89584cb4
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
||||||
|
|
||||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||||
|
|
||||||
##### Current version: 0.8.48
|
##### Current version: 0.8.49
|
||||||
|
|
||||||
| Web | UI | Preview |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
|
|
@ -88,7 +88,7 @@ func checkVersion() {
|
||||||
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
|
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
|
||||||
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
|
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
|
||||||
{"gopkg.in/macaron.v1", macaron.Version, "0.8.0"},
|
{"gopkg.in/macaron.v1", macaron.Version, "0.8.0"},
|
||||||
{"github.com/gogits/git-module", git.Version, "0.2.7"},
|
{"github.com/gogits/git-module", git.Version, "0.2.8"},
|
||||||
{"github.com/gogits/go-gogs-client", gogs.Version, "0.7.3"},
|
{"github.com/gogits/go-gogs-client", gogs.Version, "0.7.3"},
|
||||||
}
|
}
|
||||||
for _, c := range checkers {
|
for _, c := range checkers {
|
||||||
|
|
|
@ -331,6 +331,13 @@ MAX_GIT_DIFF_LINES = 10000
|
||||||
; see more on http://git-scm.com/docs/git-gc/1.7.5
|
; see more on http://git-scm.com/docs/git-gc/1.7.5
|
||||||
GC_ARGS =
|
GC_ARGS =
|
||||||
|
|
||||||
|
; Operation timeout in seconds
|
||||||
|
[git.timeout]
|
||||||
|
MIGRATE = 600
|
||||||
|
MIRROR = 300
|
||||||
|
CLONE = 300
|
||||||
|
PULL = 300
|
||||||
|
|
||||||
[i18n]
|
[i18n]
|
||||||
LANGS = en-US,zh-CN,zh-HK,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT
|
LANGS = en-US,zh-CN,zh-HK,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT
|
||||||
NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano
|
NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.8.48.0229"
|
const APP_VER = "0.8.49.0229"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -367,11 +367,16 @@ func (repo *Repository) LocalCopyPath() string {
|
||||||
|
|
||||||
func updateLocalCopy(repoPath, localPath string) error {
|
func updateLocalCopy(repoPath, localPath string) error {
|
||||||
if !com.IsExist(localPath) {
|
if !com.IsExist(localPath) {
|
||||||
if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{}); err != nil {
|
if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{
|
||||||
|
Timeout: time.Duration(setting.Git.Timeout.Clone) * time.Second,
|
||||||
|
}); err != nil {
|
||||||
return fmt.Errorf("Clone: %v", err)
|
return fmt.Errorf("Clone: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := git.Pull(localPath, true); err != nil {
|
if err := git.Pull(localPath, git.PullRemoteOptions{
|
||||||
|
All: true,
|
||||||
|
Timeout: time.Duration(setting.Git.Timeout.Pull) * time.Second,
|
||||||
|
}); err != nil {
|
||||||
return fmt.Errorf("Pull: %v", err)
|
return fmt.Errorf("Pull: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -652,7 +657,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
|
||||||
if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
|
if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
|
||||||
Mirror: true,
|
Mirror: true,
|
||||||
Quiet: true,
|
Quiet: true,
|
||||||
Timeout: 10 * time.Minute,
|
Timeout: time.Duration(setting.Git.Timeout.Migrate) * time.Second,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return repo, fmt.Errorf("Clone: %v", err)
|
return repo, fmt.Errorf("Clone: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -1610,7 +1615,8 @@ func MirrorUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
repoPath := m.Repo.RepoPath()
|
repoPath := m.Repo.RepoPath()
|
||||||
if _, stderr, err := process.ExecDir(10*time.Minute,
|
if _, stderr, err := process.ExecDir(
|
||||||
|
time.Duration(setting.Git.Timeout.Mirror)*time.Second,
|
||||||
repoPath, fmt.Sprintf("MirrorUpdate: %s", repoPath),
|
repoPath, fmt.Sprintf("MirrorUpdate: %s", repoPath),
|
||||||
"git", "remote", "update", "--prune"); err != nil {
|
"git", "remote", "update", "--prune"); err != nil {
|
||||||
desc := fmt.Sprintf("Fail to update mirror repository(%s): %s", repoPath, stderr)
|
desc := fmt.Sprintf("Fail to update mirror repository(%s): %s", repoPath, stderr)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -163,6 +163,12 @@ var (
|
||||||
Git struct {
|
Git struct {
|
||||||
MaxGitDiffLines int
|
MaxGitDiffLines int
|
||||||
GcArgs []string `delim:" "`
|
GcArgs []string `delim:" "`
|
||||||
|
Timeout struct {
|
||||||
|
Migrate int
|
||||||
|
Mirror int
|
||||||
|
Clone int
|
||||||
|
Pull int
|
||||||
|
} `ini:"git.timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cron tasks
|
// Cron tasks
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.8.48.0229
|
0.8.49.0229
|
Loading…
Reference in New Issue
Block a user