History

Fix stderr usages (#26477)

wxiaoguang committed 3 years ago

Commit 82ea5571 parent ca74b073 files · +5 −8Browse files

Showing the changes to services/gitdiff/gitdiff.go (1 of 3 files). Show all

Unified · Split

services/gitdiff/gitdiff.go+3−3
@@ -13,7 +13,6 @@ import ( · 12 unmodified lines
1313 "html/template"
1414 "io"
1515 "net/url"
16− "os"
1716 "sort"
1817 "strings"
1918 "time"
@@ -1152,14 +1151,15 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff · 1132 unmodified lines
11521151 }()
11531152
11541153 go func() {
1154+ stderr := &bytes.Buffer{}
11551155 cmdDiff.SetDescription(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath))
11561156 if err := cmdDiff.Run(&git.RunOpts{
11571157 Timeout: time.Duration(setting.Git.Timeout.Default) * time.Second,
11581158 Dir: repoPath,
1159− Stderr: os.Stderr,
11601159 Stdout: writer,
1160+ Stderr: stderr,
11611161 }); err != nil {
1162− log.Error("error during RunWithContext: %w", err)
1162+ log.Error("error during GetDiff(git diff dir: %s): %v, stderr: %s", repoPath, err, stderr.String())
11631163 }
11641164
11651165 _ = writer.Close()