Refactor git command stderr handling (#36402)

And clean up legacy fragile & incorrect logic
This commit is contained in:
wxiaoguang
2026-01-19 07:10:33 +08:00
committed by GitHub
parent fafd1db19e
commit 72be55f7d3
69 changed files with 345 additions and 627 deletions

View File

@@ -5,7 +5,6 @@ package git
import (
"bufio"
"bytes"
"context"
"fmt"
"io"
@@ -80,14 +79,9 @@ func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diff
return fmt.Errorf("invalid diffType: %s", diffType)
}
stderr := new(bytes.Buffer)
if err = cmd.WithDir(repo.Path).
return cmd.WithDir(repo.Path).
WithStdout(writer).
WithStderr(stderr).
Run(repo.Ctx); err != nil {
return fmt.Errorf("Run: %w - %s", err, stderr)
}
return nil
RunWithStderr(repo.Ctx)
}
// ParseDiffHunkString parse the diff hunk content and return