refactor: use RunWithStderr for git commands (#40295)

If the stderr output is not handled, then it needs to use RunWithStderr
to make sure the git error message is included in the returned error.
Otherwise, when the git command fails, the error log won't show useful
information.

Ref:

* #39795 : no useful information in log messages
*
https://github.com/go-gitea/gitea/pull/40160#pullrequestreview-5752720866
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-11-09 17:59:52 +00:00
1 parent e0b2f3425e
commit 772f365254
26 files changed
+57 -47

No files matched your search

+1 -1
View File
@@ -1049,7 +1049,7 @@ revert
from :2
D test2.txt
D test10.txt`
require.NoError(t, gitcmd.NewCommand("fast-import").WithRepo(pull.BaseRepo).WithStdinBytes([]byte(stdin)).Run(t.Context()))
require.NoError(t, gitcmd.NewCommand("fast-import").WithRepo(pull.BaseRepo).WithStdinBytes([]byte(stdin)).RunWithStderr(t.Context()))
gitRepo, err := git.OpenRepository(t.Context(), pull.BaseRepo)
assert.NoError(t, err)