Skip to content

Commit aa4d784

Browse files
earl-warrenGusted
andauthored
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>
1 parent f4ea8d9 commit aa4d784

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

services/pull/pull.go

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package pull
55

66
import (
7+
"bytes"
78
"context"
89
"fmt"
910
"io"
@@ -422,9 +423,11 @@ func checkIfPRContentChanged(ctx context.Context, pr *issues_model.PullRequest,
422423
return false, fmt.Errorf("unable to open pipe for to run diff: %w", err)
423424
}
424425

426+
stderr := new(bytes.Buffer)
425427
if err := cmd.Run(&git.RunOpts{
426428
Dir: prCtx.tmpBasePath,
427429
Stdout: stdoutWriter,
430+
Stderr: stderr,
428431
PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error {
429432
_ = stdoutWriter.Close()
430433
defer func() {
@@ -436,6 +439,7 @@ func checkIfPRContentChanged(ctx context.Context, pr *issues_model.PullRequest,
436439
if err == util.ErrNotEmpty {
437440
return true, nil
438441
}
442+
err = git.ConcatenateError(err, stderr.String())
439443

440444
log.Error("Unable to run diff on %s %s %s in tempRepo for PR[%d]%s/%s...%s/%s: Error: %v",
441445
newCommitID, oldCommitID, base,

0 commit comments

Comments
 (0)