Skip to content

Commit

Permalink
Concatenate error in checkIfPRContentChanged (#28731)
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
earl-warren and Gusted authored Jan 9, 2024
1 parent f4ea8d9 commit aa4d784
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions services/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package pull

import (
"bytes"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -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)
}

stderr := new(bytes.Buffer)
if err := cmd.Run(&git.RunOpts{
Dir: prCtx.tmpBasePath,
Stdout: stdoutWriter,
Stderr: stderr,
PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error {
_ = stdoutWriter.Close()
defer func() {
Expand All @@ -436,6 +439,7 @@ func checkIfPRContentChanged(ctx context.Context, pr *issues_model.PullRequest,
if err == util.ErrNotEmpty {
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",
newCommitID, oldCommitID, base,
Expand Down

0 comments on commit aa4d784

Please sign in to comment.