mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-27 20:49:33 +08:00
Concatenate error in checkIfPRContentChanged
(#28731)
- If there's a error with the Git command in `checkIfPRContentChanged` the stderr wasn't concatendated to the error, which results in still not knowing why an error happend. - Adds concatenation for stderr to the returned error. - Ref: https://codeberg.org/forgejo/forgejo/issues/2077 Co-authored-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
f4ea8d9a6c
commit
aa4d78431f
@ -4,6 +4,7 @@
|
|||||||
package pull
|
package pull
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -422,9 +423,11 @@ func checkIfPRContentChanged(ctx context.Context, pr *issues_model.PullRequest,
|
|||||||
return false, fmt.Errorf("unable to open pipe for to run diff: %w", err)
|
return false, fmt.Errorf("unable to open pipe for to run diff: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stderr := new(bytes.Buffer)
|
||||||
if err := cmd.Run(&git.RunOpts{
|
if err := cmd.Run(&git.RunOpts{
|
||||||
Dir: prCtx.tmpBasePath,
|
Dir: prCtx.tmpBasePath,
|
||||||
Stdout: stdoutWriter,
|
Stdout: stdoutWriter,
|
||||||
|
Stderr: stderr,
|
||||||
PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error {
|
PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error {
|
||||||
_ = stdoutWriter.Close()
|
_ = stdoutWriter.Close()
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -436,6 +439,7 @@ func checkIfPRContentChanged(ctx context.Context, pr *issues_model.PullRequest,
|
|||||||
if err == util.ErrNotEmpty {
|
if err == util.ErrNotEmpty {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
err = git.ConcatenateError(err, stderr.String())
|
||||||
|
|
||||||
log.Error("Unable to run diff on %s %s %s in tempRepo for PR[%d]%s/%s...%s/%s: Error: %v",
|
log.Error("Unable to run diff on %s %s %s in tempRepo for PR[%d]%s/%s...%s/%s: Error: %v",
|
||||||
newCommitID, oldCommitID, base,
|
newCommitID, oldCommitID, base,
|
||||||
|
Loading…
Reference in New Issue
Block a user