0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-10-26 16:54:23 -04:00

Fix merge panic (#35606)

To prevent potential bugs, the logic in #35543 makes `gitcmd.Command`
panic when attempting to override stdout or stderr. Instead of using
`PrepareCmd`, this PR now uses the WithXXX methods directly to avoid the
panic.

Fix #35603
This commit is contained in:
Lunny Xiao
2025-10-11 19:24:00 -07:00
committed by GitHub
parent 24a595c3fc
commit 662a44d924
6 changed files with 114 additions and 18 deletions

View File

@@ -37,6 +37,9 @@ type prTmpRepoContext struct {
errbuf *strings.Builder // any use should be preceded by a Reset and preferably after use
}
// PrepareGitCmd prepares a git command with the correct directory, environment, and output buffers
// This function can only be called with gitcmd.Run()
// Do NOT use it with gitcmd.RunStd*() functions, otherwise it will panic
func (ctx *prTmpRepoContext) PrepareGitCmd(cmd *gitcmd.Command) *gitcmd.Command {
ctx.outbuf.Reset()
ctx.errbuf.Reset()