Add git diff timeout in app config (#6348)

Co-authored-by: ᴜɴᴋɴᴡᴏɴ <u@gogs.io>
pull/6358/merge
Zhukov Roman 2020-09-29 18:12:17 +03:00 committed by GitHub
parent 23823e9698
commit be86d67e81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 252 additions and 246 deletions

View File

@ -7,6 +7,7 @@ All notable changes to Gogs are documented in this file.
### Added
- An unlisted option is added when create or migrate a repository. Unlisted repositories are public but not being listed for users without direct access in the UI. [#5733](https://github.com/gogs/gogs/issues/5733)
- Add new configuration option `[git.timeout] DIFF` for customizing operation timeout of `git diff`. [#6315](https://github.com/gogs/gogs/issues/6315)
### Changed

View File

@ -460,6 +460,7 @@ MIGRATE = 600
MIRROR = 300
CLONE = 300
PULL = 300
DIFF = 60
GC = 60
[mirror]

File diff suppressed because one or more lines are too long

View File

@ -283,6 +283,7 @@ var (
Mirror int
Clone int
Pull int
Diff int
GC int `ini:"GC"`
} `ini:"git.timeout"`
}

View File

@ -6,6 +6,7 @@ package repo
import (
"path"
"time"
"github.com/gogs/git-module"
@ -125,6 +126,7 @@ func Diff(c *context.Context) {
diff, err := gitutil.RepoDiff(c.Repo.GitRepo,
commitID, conf.Git.MaxDiffFiles, conf.Git.MaxDiffLines, conf.Git.MaxDiffLineChars,
git.DiffOptions{Timeout: time.Duration(conf.Git.Timeout.Diff) * time.Second},
)
if err != nil {
c.NotFoundOrError(gitutil.NewError(err), "get diff")
@ -193,7 +195,7 @@ func CompareDiff(c *context.Context) {
diff, err := gitutil.RepoDiff(c.Repo.GitRepo,
afterCommitID, conf.Git.MaxDiffFiles, conf.Git.MaxDiffLines, conf.Git.MaxDiffLineChars,
git.DiffOptions{Base: beforeCommitID},
git.DiffOptions{Base: beforeCommitID, Timeout: time.Duration(conf.Git.Timeout.Diff) * time.Second},
)
if err != nil {
c.NotFoundOrError(gitutil.NewError(err), "get diff")

View File

@ -8,6 +8,7 @@ import (
"net/http"
"path"
"strings"
"time"
"github.com/unknwon/com"
log "unknwon.dev/clog/v2"
@ -354,7 +355,7 @@ func ViewPullFiles(c *context.Context) {
diff, err := gitutil.RepoDiff(diffGitRepo,
endCommitID, conf.Git.MaxDiffFiles, conf.Git.MaxDiffLines, conf.Git.MaxDiffLineChars,
git.DiffOptions{Base: startCommitID},
git.DiffOptions{Base: startCommitID, Timeout: time.Duration(conf.Git.Timeout.Diff) * time.Second},
)
if err != nil {
c.Error(err, "get diff")
@ -575,7 +576,7 @@ func PrepareCompareDiff(
diff, err := gitutil.RepoDiff(headGitRepo,
headCommitID, conf.Git.MaxDiffFiles, conf.Git.MaxDiffLines, conf.Git.MaxDiffLineChars,
git.DiffOptions{Base: meta.MergeBase},
git.DiffOptions{Base: meta.MergeBase, Timeout: time.Duration(conf.Git.Timeout.Diff) * time.Second},
)
if err != nil {
c.Error(err, "get repository diff")