diff options
author | delvh <leon@kske.dev> | 2022-10-24 21:29:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 20:29:17 +0100 |
commit | 0ebb45cfe7606adf021ad359d6fbfcefc54360a5 (patch) | |
tree | 541b75d083213e93bbbfadbdc5d560c739543903 /services/agit | |
parent | 7c11a73833f3aa9783015e5e13871d3c298d3ef6 (diff) | |
download | gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.tar.gz gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.zip |
Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)
Found using
`find . -type f -name '*.go' -print -exec vim {} -c
':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;`
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'services/agit')
-rw-r--r-- | services/agit/agit.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/services/agit/agit.go b/services/agit/agit.go index cea2b1f580..a7e701d6c4 100644 --- a/services/agit/agit.go +++ b/services/agit/agit.go @@ -99,7 +99,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. pr, err := issues_model.GetUnmergedPullRequest(repo.ID, repo.ID, headBranch, baseBranchName, issues_model.PullRequestFlowAGit) if err != nil { if !issues_model.IsErrPullRequestNotExist(err) { - return nil, fmt.Errorf("Failed to get unmerged agit flow pull request in repository: %s/%s Error: %v", ownerName, repoName, err) + return nil, fmt.Errorf("Failed to get unmerged agit flow pull request in repository: %s/%s Error: %w", ownerName, repoName, err) } // create a new pull request @@ -109,7 +109,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. if !has || len(title) == 0 { commit, err := gitRepo.GetCommit(opts.NewCommitIDs[i]) if err != nil { - return nil, fmt.Errorf("Failed to get commit %s in repository: %s/%s Error: %v", opts.NewCommitIDs[i], ownerName, repoName, err) + return nil, fmt.Errorf("Failed to get commit %s in repository: %s/%s Error: %w", opts.NewCommitIDs[i], ownerName, repoName, err) } title = strings.Split(commit.CommitMessage, "\n")[0] } @@ -118,7 +118,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. pusher, err := user_model.GetUserByID(opts.UserID) if err != nil { - return nil, fmt.Errorf("Failed to get user. Error: %v", err) + return nil, fmt.Errorf("Failed to get user. Error: %w", err) } prIssue := &issues_model.Issue{ @@ -160,12 +160,12 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. // update exist pull request if err := pr.LoadBaseRepoCtx(ctx); err != nil { - return nil, fmt.Errorf("Unable to load base repository for PR[%d] Error: %v", pr.ID, err) + return nil, fmt.Errorf("Unable to load base repository for PR[%d] Error: %w", pr.ID, err) } oldCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName()) if err != nil { - return nil, fmt.Errorf("Unable to get ref commit id in base repository for PR[%d] Error: %v", pr.ID, err) + return nil, fmt.Errorf("Unable to get ref commit id in base repository for PR[%d] Error: %w", pr.ID, err) } if oldCommitID == opts.NewCommitIDs[i] { @@ -181,7 +181,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. if !forcePush { output, _, err := git.NewCommand(ctx, "rev-list", "--max-count=1").AddDynamicArguments(oldCommitID, "^"+opts.NewCommitIDs[i]).RunStdString(&git.RunOpts{Dir: repo.RepoPath(), Env: os.Environ()}) if err != nil { - return nil, fmt.Errorf("Fail to detect force push: %v", err) + return nil, fmt.Errorf("Fail to detect force push: %w", err) } else if len(output) > 0 { results = append(results, private.HookProcReceiveRefResult{ OriginalRef: opts.RefFullNames[i], @@ -195,17 +195,17 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. pr.HeadCommitID = opts.NewCommitIDs[i] if err = pull_service.UpdateRef(ctx, pr); err != nil { - return nil, fmt.Errorf("Failed to update pull ref. Error: %v", err) + return nil, fmt.Errorf("Failed to update pull ref. Error: %w", err) } pull_service.AddToTaskQueue(pr) pusher, err := user_model.GetUserByID(opts.UserID) if err != nil { - return nil, fmt.Errorf("Failed to get user. Error: %v", err) + return nil, fmt.Errorf("Failed to get user. Error: %w", err) } err = pr.LoadIssue() if err != nil { - return nil, fmt.Errorf("Failed to load pull issue. Error: %v", err) + return nil, fmt.Errorf("Failed to load pull issue. Error: %w", err) } comment, err := issues_model.CreatePushPullComment(ctx, pusher, pr, oldCommitID, opts.NewCommitIDs[i]) if err == nil && comment != nil { |