Fix stderr usages (#26477)

This commit is contained in:
wxiaoguang 2023-08-13 20:49:30 +08:00 committed by GitHub
parent ca74b074ea
commit 82ea557dd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View file

@ -13,7 +13,6 @@ import (
"html/template"
"io"
"net/url"
"os"
"sort"
"strings"
"time"
@ -1152,14 +1151,15 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff
}()
go func() {
stderr := &bytes.Buffer{}
cmdDiff.SetDescription(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath))
if err := cmdDiff.Run(&git.RunOpts{
Timeout: time.Duration(setting.Git.Timeout.Default) * time.Second,
Dir: repoPath,
Stderr: os.Stderr,
Stdout: writer,
Stderr: stderr,
}); err != nil {
log.Error("error during RunWithContext: %w", err)
log.Error("error during GetDiff(git diff dir: %s): %v, stderr: %s", repoPath, err, stderr.String())
}
_ = writer.Close()