Просмотр исходного кода

Allow setting git operations timeouts

- Migrate: #2704 #2653
- Clone: #2701
- Mirror, Pull
Unknwon лет назад: 8
Родитель
Сommit
9e89584cb4
8 измененных файлов с 29 добавлено и 10 удалено
  1. 1 1
      README.md
  2. 1 1
      cmd/web.go
  3. 7 0
      conf/app.ini
  4. 1 1
      gogs.go
  5. 10 4
      models/repo.go
  6. 2 2
      modules/bindata/bindata.go
  7. 6 0
      modules/setting/setting.go
  8. 1 1
      templates/.VERSION

+ 1 - 1
README.md

@@ -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)
 
-##### Current version: 0.8.48
+##### Current version: 0.8.49
 
 | Web | UI  | Preview  |
 |:-------------:|:-------:|:-------:|

+ 1 - 1
cmd/web.go

@@ -88,7 +88,7 @@ func checkVersion() {
 		{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
 		{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
 		{"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"},
 	}
 	for _, c := range checkers {

+ 7 - 0
conf/app.ini

@@ -331,6 +331,13 @@ MAX_GIT_DIFF_LINES = 10000
 ; see more on http://git-scm.com/docs/git-gc/1.7.5
 GC_ARGS = 
 
+; Operation timeout in seconds
+[git.timeout]
+MIGRATE = 600
+MIRROR = 300
+CLONE = 300
+PULL = 300
+
 [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
 NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano

+ 1 - 1
gogs.go

@@ -17,7 +17,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.8.48.0229"
+const APP_VER = "0.8.49.0229"
 
 func init() {
 	runtime.GOMAXPROCS(runtime.NumCPU())

+ 10 - 4
models/repo.go

@@ -367,11 +367,16 @@ func (repo *Repository) LocalCopyPath() string {
 
 func updateLocalCopy(repoPath, localPath string) error {
 	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)
 		}
 	} 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)
 		}
 	}
@@ -652,7 +657,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
 	if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
 		Mirror:  true,
 		Quiet:   true,
-		Timeout: 10 * time.Minute,
+		Timeout: time.Duration(setting.Git.Timeout.Migrate) * time.Second,
 	}); err != nil {
 		return repo, fmt.Errorf("Clone: %v", err)
 	}
@@ -1610,7 +1615,8 @@ func MirrorUpdate() {
 		}
 
 		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),
 			"git", "remote", "update", "--prune"); err != nil {
 			desc := fmt.Sprintf("Fail to update mirror repository(%s): %s", repoPath, stderr)

Разница между файлами не показана из-за своего большого размера
+ 2 - 2
modules/bindata/bindata.go


+ 6 - 0
modules/setting/setting.go

@@ -163,6 +163,12 @@ var (
 	Git struct {
 		MaxGitDiffLines int
 		GcArgs          []string `delim:" "`
+		Timeout         struct {
+			Migrate int
+			Mirror  int
+			Clone   int
+			Pull    int
+		} `ini:"git.timeout"`
 	}
 
 	// Cron tasks

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.8.48.0229
+0.8.49.0229