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

+3
View File
@@ -568,6 +568,9 @@ func (c *Command) RunWithStderr(ctx context.Context) RunStdError {
return c.WaitWithStderr()
}
// Run runs the command and leaves stderr handling to the caller, such as through [Command.MakeStderrPipe].
// Without a stderr reader, Git's diagnostics are discarded and the error may only report an exit status.
// Use [Command.RunWithStderr] to include Git's stderr in the returned error.
func (c *Command) Run(ctx context.Context) (err error) {
if err = c.WithParentCallerInfo().Start(ctx); err != nil {
return err