Merge pull request 'git-grep: set timeout to 2s by default and allow configuring it' (#4966) from yoctozepto/git-grep-timeout into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4966
Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
Otto 2024-08-15 12:15:16 +00:00
commit d26ad8dbe5
3 changed files with 7 additions and 0 deletions

View file

@ -15,6 +15,7 @@ import (
"os"
"strconv"
"strings"
"time"
"code.gitea.io/gitea/modules/setting"
)
@ -94,6 +95,8 @@ func GrepSearch(ctx context.Context, repo *Repository, search string, opts GrepO
opts.MaxResultLimit = cmp.Or(opts.MaxResultLimit, 50)
stderr := bytes.Buffer{}
err = cmd.Run(&RunOpts{
Timeout: time.Duration(setting.Git.Timeout.Grep) * time.Second,
Dir: repo.Path,
Stdout: stdoutWriter,
Stderr: &stderr,