Skip to content

Commit 9e89584

Browse files
committed
Allow setting git operations timeouts
- Migrate: #2704 #2653 - Clone: #2701 - Mirror, Pull
1 parent ea80274 commit 9e89584

File tree

8 files changed

+29
-10
lines changed

8 files changed

+29
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
33

44
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
55

6-
##### Current version: 0.8.48
6+
##### Current version: 0.8.49
77

88
| Web | UI | Preview |
99
|:-------------:|:-------:|:-------:|

cmd/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func checkVersion() {
8888
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
8989
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
9090
{"gopkg.in/macaron.v1", macaron.Version, "0.8.0"},
91-
{"github.com/gogits/git-module", git.Version, "0.2.7"},
91+
{"github.com/gogits/git-module", git.Version, "0.2.8"},
9292
{"github.com/gogits/go-gogs-client", gogs.Version, "0.7.3"},
9393
}
9494
for _, c := range checkers {

conf/app.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ MAX_GIT_DIFF_LINES = 10000
331331
; see more on http://git-scm.com/docs/git-gc/1.7.5
332332
GC_ARGS =
333333

334+
; Operation timeout in seconds
335+
[git.timeout]
336+
MIGRATE = 600
337+
MIRROR = 300
338+
CLONE = 300
339+
PULL = 300
340+
334341
[i18n]
335342
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
336343
NAMES = English,简体中文,繁體中文,Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano

gogs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/gogits/gogs/modules/setting"
1818
)
1919

20-
const APP_VER = "0.8.48.0229"
20+
const APP_VER = "0.8.49.0229"
2121

2222
func init() {
2323
runtime.GOMAXPROCS(runtime.NumCPU())

models/repo.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,16 @@ func (repo *Repository) LocalCopyPath() string {
367367

368368
func updateLocalCopy(repoPath, localPath string) error {
369369
if !com.IsExist(localPath) {
370-
if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{}); err != nil {
370+
if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{
371+
Timeout: time.Duration(setting.Git.Timeout.Clone) * time.Second,
372+
}); err != nil {
371373
return fmt.Errorf("Clone: %v", err)
372374
}
373375
} else {
374-
if err := git.Pull(localPath, true); err != nil {
376+
if err := git.Pull(localPath, git.PullRemoteOptions{
377+
All: true,
378+
Timeout: time.Duration(setting.Git.Timeout.Pull) * time.Second,
379+
}); err != nil {
375380
return fmt.Errorf("Pull: %v", err)
376381
}
377382
}
@@ -652,7 +657,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
652657
if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
653658
Mirror: true,
654659
Quiet: true,
655-
Timeout: 10 * time.Minute,
660+
Timeout: time.Duration(setting.Git.Timeout.Migrate) * time.Second,
656661
}); err != nil {
657662
return repo, fmt.Errorf("Clone: %v", err)
658663
}
@@ -1610,7 +1615,8 @@ func MirrorUpdate() {
16101615
}
16111616

16121617
repoPath := m.Repo.RepoPath()
1613-
if _, stderr, err := process.ExecDir(10*time.Minute,
1618+
if _, stderr, err := process.ExecDir(
1619+
time.Duration(setting.Git.Timeout.Mirror)*time.Second,
16141620
repoPath, fmt.Sprintf("MirrorUpdate: %s", repoPath),
16151621
"git", "remote", "update", "--prune"); err != nil {
16161622
desc := fmt.Sprintf("Fail to update mirror repository(%s): %s", repoPath, stderr)

modules/bindata/bindata.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/setting/setting.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ var (
163163
Git struct {
164164
MaxGitDiffLines int
165165
GcArgs []string `delim:" "`
166+
Timeout struct {
167+
Migrate int
168+
Mirror int
169+
Clone int
170+
Pull int
171+
} `ini:"git.timeout"`
166172
}
167173

168174
// Cron tasks

templates/.VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.48.0229
1+
0.8.49.0229

0 commit comments

Comments
 (0)