History

[PORT] Fix git error handling (gitea#32401)

--- Conflict resolution: Trivial, for `repo_attributes.go` move where the `IsErrCanceledOrKilled` needs to happen because of other changes that happened in this file. To add some words to this change: It seems to be mostly simplifying the error handling of git operations. (cherry picked from commit e524f63d58900557d7d57fc3bcd19d9facc8b8ee)

wxiaoguang committed 2 years ago

Commit 171de4d1 parent 20c0a2a11 files · +36 −86Browse files

Showing the changes to services/gitdiff/gitdiff.go (1 of 11 files). Show all

Unified · Split

services/gitdiff/gitdiff.go+1−1
@@ -1159,7 +1159,7 @@ func GetDiff(ctx context.Context, gitRepo *git.Repository, opts *DiffOptions, fi · 1158 unmodified lines
1159 Dir: repoPath,1159 Dir: repoPath,
1160 Stdout: writer,1160 Stdout: writer,
1161 Stderr: stderr,1161 Stderr: stderr,
1162 }); err != nil {1162 }); err != nil && !git.IsErrCanceledOrKilled(err) {
1163 log.Error("error during GetDiff(git diff dir: %s): %v, stderr: %s", repoPath, err, stderr.String())1163 log.Error("error during GetDiff(git diff dir: %s): %v, stderr: %s", repoPath, err, stderr.String())
1164 }1164 }
1165 1165