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/migrations | |
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/migrations')
-rw-r--r-- | services/migrations/dump.go | 6 | ||||
-rw-r--r-- | services/migrations/gitea_downloader.go | 6 | ||||
-rw-r--r-- | services/migrations/gitea_uploader.go | 4 | ||||
-rw-r--r-- | services/migrations/github.go | 14 | ||||
-rw-r--r-- | services/migrations/gitlab.go | 10 | ||||
-rw-r--r-- | services/migrations/gogs.go | 4 |
6 files changed, 22 insertions, 22 deletions
diff --git a/services/migrations/dump.go b/services/migrations/dump.go index 31fb1b4cf3..4ab4539c89 100644 --- a/services/migrations/dump.go +++ b/services/migrations/dump.go @@ -157,7 +157,7 @@ func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOp SkipTLSVerify: setting.Migrations.SkipTLSVerify, }) if err != nil { - return fmt.Errorf("Clone: %v", err) + return fmt.Errorf("Clone: %w", err) } if err := git.WriteCommitGraph(g.ctx, repoPath); err != nil { return err @@ -168,7 +168,7 @@ func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOp wikiRemotePath := repository.WikiRemoteURL(g.ctx, remoteAddr) if len(wikiRemotePath) > 0 { if err := os.MkdirAll(wikiPath, os.ModePerm); err != nil { - return fmt.Errorf("Failed to remove %s: %v", wikiPath, err) + return fmt.Errorf("Failed to remove %s: %w", wikiPath, err) } if err := git.Clone(g.ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{ @@ -180,7 +180,7 @@ func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOp }); err != nil { log.Warn("Clone wiki: %v", err) if err := os.RemoveAll(wikiPath); err != nil { - return fmt.Errorf("Failed to remove %s: %v", wikiPath, err) + return fmt.Errorf("Failed to remove %s: %w", wikiPath, err) } } else if err := git.WriteCommitGraph(g.ctx, wikiPath); err != nil { return err diff --git a/services/migrations/gitea_downloader.go b/services/migrations/gitea_downloader.go index c52f302691..9775af1cdc 100644 --- a/services/migrations/gitea_downloader.go +++ b/services/migrations/gitea_downloader.go @@ -408,7 +408,7 @@ func (g *GiteaDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, err Type: gitea_sdk.IssueTypeIssue, }) if err != nil { - return nil, false, fmt.Errorf("error while listing issues: %v", err) + return nil, false, fmt.Errorf("error while listing issues: %w", err) } for _, issue := range issues { @@ -476,7 +476,7 @@ func (g *GiteaDownloader) GetComments(commentable base.Commentable) ([]*base.Com Page: i, }}) if err != nil { - return nil, false, fmt.Errorf("error while listing comments for issue #%d. Error: %v", commentable.GetForeignIndex(), err) + return nil, false, fmt.Errorf("error while listing comments for issue #%d. Error: %w", commentable.GetForeignIndex(), err) } for _, comment := range comments { @@ -520,7 +520,7 @@ func (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullReques State: gitea_sdk.StateAll, }) if err != nil { - return nil, false, fmt.Errorf("error while listing pull requests (page: %d, pagesize: %d). Error: %v", page, perPage, err) + return nil, false, fmt.Errorf("error while listing pull requests (page: %d, pagesize: %d). Error: %w", page, perPage, err) } for _, pr := range prs { var milestone string diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index c4cb59f572..8a7533b3d1 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -288,12 +288,12 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { commit, err := g.gitRepo.GetTagCommit(rel.TagName) if !git.IsErrNotExist(err) { if err != nil { - return fmt.Errorf("GetTagCommit[%v]: %v", rel.TagName, err) + return fmt.Errorf("GetTagCommit[%v]: %w", rel.TagName, err) } rel.Sha1 = commit.ID.String() rel.NumCommits, err = commit.CommitsCount() if err != nil { - return fmt.Errorf("CommitsCount: %v", err) + return fmt.Errorf("CommitsCount: %w", err) } } } diff --git a/services/migrations/github.go b/services/migrations/github.go index 0ffdbb042a..016d058865 100644 --- a/services/migrations/github.go +++ b/services/migrations/github.go @@ -427,7 +427,7 @@ func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool, g.waitAndPickClient() issues, resp, err := g.getClient().Issues.ListByRepo(g.ctx, g.repoOwner, g.repoName, opt) if err != nil { - return nil, false, fmt.Errorf("error while listing repos: %v", err) + return nil, false, fmt.Errorf("error while listing repos: %w", err) } log.Trace("Request get issues %d/%d, but in fact get %d", perPage, page, len(issues)) g.setRate(&resp.Rate) @@ -523,7 +523,7 @@ func (g *GithubDownloaderV3) getComments(commentable base.Commentable) ([]*base. g.waitAndPickClient() comments, resp, err := g.getClient().Issues.ListComments(g.ctx, g.repoOwner, g.repoName, int(commentable.GetForeignIndex()), opt) if err != nil { - return nil, fmt.Errorf("error while listing repos: %v", err) + return nil, fmt.Errorf("error while listing repos: %w", err) } g.setRate(&resp.Rate) for _, comment := range comments { @@ -595,7 +595,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment, g.waitAndPickClient() comments, resp, err := g.getClient().Issues.ListComments(g.ctx, g.repoOwner, g.repoName, 0, opt) if err != nil { - return nil, false, fmt.Errorf("error while listing repos: %v", err) + return nil, false, fmt.Errorf("error while listing repos: %w", err) } isEnd := resp.NextPage == 0 @@ -663,7 +663,7 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq g.waitAndPickClient() prs, resp, err := g.getClient().PullRequests.List(g.ctx, g.repoOwner, g.repoName, opt) if err != nil { - return nil, false, fmt.Errorf("error while listing repos: %v", err) + return nil, false, fmt.Errorf("error while listing repos: %w", err) } log.Trace("Request get pull requests %d/%d, but in fact get %d", perPage, page, len(prs)) g.setRate(&resp.Rate) @@ -813,7 +813,7 @@ func (g *GithubDownloaderV3) GetReviews(reviewable base.Reviewable) ([]*base.Rev g.waitAndPickClient() reviews, resp, err := g.getClient().PullRequests.ListReviews(g.ctx, g.repoOwner, g.repoName, int(reviewable.GetForeignIndex()), opt) if err != nil { - return nil, fmt.Errorf("error while listing repos: %v", err) + return nil, fmt.Errorf("error while listing repos: %w", err) } g.setRate(&resp.Rate) for _, review := range reviews { @@ -827,7 +827,7 @@ func (g *GithubDownloaderV3) GetReviews(reviewable base.Reviewable) ([]*base.Rev g.waitAndPickClient() reviewComments, resp, err := g.getClient().PullRequests.ListReviewComments(g.ctx, g.repoOwner, g.repoName, int(reviewable.GetForeignIndex()), review.GetID(), opt2) if err != nil { - return nil, fmt.Errorf("error while listing repos: %v", err) + return nil, fmt.Errorf("error while listing repos: %w", err) } g.setRate(&resp.Rate) @@ -853,7 +853,7 @@ func (g *GithubDownloaderV3) GetReviews(reviewable base.Reviewable) ([]*base.Rev g.waitAndPickClient() reviewers, resp, err := g.getClient().PullRequests.ListReviewers(g.ctx, g.repoOwner, g.repoName, int(reviewable.GetForeignIndex()), opt) if err != nil { - return nil, fmt.Errorf("error while listing repos: %v", err) + return nil, fmt.Errorf("error while listing repos: %w", err) } g.setRate(&resp.Rate) for _, user := range reviewers.Users { diff --git a/services/migrations/gitlab.go b/services/migrations/gitlab.go index 95bec59e83..b8bb0c77b5 100644 --- a/services/migrations/gitlab.go +++ b/services/migrations/gitlab.go @@ -398,7 +398,7 @@ func (g *GitlabDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, er issues, _, err := g.client.Issues.ListProjectIssues(g.repoID, opt, nil, gitlab.WithContext(g.ctx)) if err != nil { - return nil, false, fmt.Errorf("error while listing issues: %v", err) + return nil, false, fmt.Errorf("error while listing issues: %w", err) } for _, issue := range issues { @@ -419,7 +419,7 @@ func (g *GitlabDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, er for { awards, _, err := g.client.AwardEmoji.ListIssueAwardEmoji(g.repoID, issue.IID, &gitlab.ListAwardEmojiOptions{Page: awardPage, PerPage: perPage}, gitlab.WithContext(g.ctx)) if err != nil { - return nil, false, fmt.Errorf("error while listing issue awards: %v", err) + return nil, false, fmt.Errorf("error while listing issue awards: %w", err) } for i := range awards { @@ -487,7 +487,7 @@ func (g *GitlabDownloader) GetComments(commentable base.Commentable) ([]*base.Co } if err != nil { - return nil, false, fmt.Errorf("error while listing comments: %v %v", g.repoID, err) + return nil, false, fmt.Errorf("error while listing comments: %v %w", g.repoID, err) } for _, comment := range comments { // Flatten comment threads @@ -541,7 +541,7 @@ func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullReque prs, _, err := g.client.MergeRequests.ListProjectMergeRequests(g.repoID, opt, nil, gitlab.WithContext(g.ctx)) if err != nil { - return nil, false, fmt.Errorf("error while listing merge requests: %v", err) + return nil, false, fmt.Errorf("error while listing merge requests: %w", err) } for _, pr := range prs { @@ -583,7 +583,7 @@ func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullReque for { awards, _, err := g.client.AwardEmoji.ListMergeRequestAwardEmoji(g.repoID, pr.IID, &gitlab.ListAwardEmojiOptions{Page: awardPage, PerPage: perPage}, gitlab.WithContext(g.ctx)) if err != nil { - return nil, false, fmt.Errorf("error while listing merge requests awards: %v", err) + return nil, false, fmt.Errorf("error while listing merge requests awards: %w", err) } for i := range awards { diff --git a/services/migrations/gogs.go b/services/migrations/gogs.go index 46cc3ca416..14bc734c4e 100644 --- a/services/migrations/gogs.go +++ b/services/migrations/gogs.go @@ -223,7 +223,7 @@ func (g *GogsDownloader) getIssues(page int, state string) ([]*base.Issue, bool, State: state, }) if err != nil { - return nil, false, fmt.Errorf("error while listing repos: %v", err) + return nil, false, fmt.Errorf("error while listing repos: %w", err) } for _, issue := range issues { @@ -242,7 +242,7 @@ func (g *GogsDownloader) GetComments(commentable base.Commentable) ([]*base.Comm comments, err := g.client.ListIssueComments(g.repoOwner, g.repoName, commentable.GetForeignIndex()) if err != nil { - return nil, false, fmt.Errorf("error while listing repos: %v", err) + return nil, false, fmt.Errorf("error while listing repos: %w", err) } for _, comment := range comments { if len(comment.Body) == 0 || comment.Poster == nil { |