aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues
diff options
context:
space:
mode:
authordelvh <leon@kske.dev>2022-10-24 21:29:17 +0200
committerGitHub <noreply@github.com>2022-10-24 20:29:17 +0100
commit0ebb45cfe7606adf021ad359d6fbfcefc54360a5 (patch)
tree541b75d083213e93bbbfadbdc5d560c739543903 /models/issues
parent7c11a73833f3aa9783015e5e13871d3c298d3ef6 (diff)
downloadgitea-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 'models/issues')
-rw-r--r--models/issues/assignees.go6
-rw-r--r--models/issues/comment.go12
-rw-r--r--models/issues/issue.go88
-rw-r--r--models/issues/issue_list.go42
-rw-r--r--models/issues/issue_user.go2
-rw-r--r--models/issues/issue_xref.go2
-rw-r--r--models/issues/label.go2
-rw-r--r--models/issues/pull.go18
-rw-r--r--models/issues/pull_list.go4
-rw-r--r--models/issues/reaction.go2
-rw-r--r--models/issues/review.go10
11 files changed, 94 insertions, 94 deletions
diff --git a/models/issues/assignees.go b/models/issues/assignees.go
index 7f589f5d7e..d960d5ebaf 100644
--- a/models/issues/assignees.go
+++ b/models/issues/assignees.go
@@ -85,12 +85,12 @@ func ToggleIssueAssignee(issue *Issue, doer *user_model.User, assigneeID int64)
func toggleIssueAssignee(ctx context.Context, issue *Issue, doer *user_model.User, assigneeID int64, isCreate bool) (removed bool, comment *Comment, err error) {
removed, err = toggleUserAssignee(ctx, issue, assigneeID)
if err != nil {
- return false, nil, fmt.Errorf("UpdateIssueUserByAssignee: %v", err)
+ return false, nil, fmt.Errorf("UpdateIssueUserByAssignee: %w", err)
}
// Repo infos
if err = issue.LoadRepo(ctx); err != nil {
- return false, nil, fmt.Errorf("loadRepo: %v", err)
+ return false, nil, fmt.Errorf("loadRepo: %w", err)
}
opts := &CreateCommentOptions{
@@ -104,7 +104,7 @@ func toggleIssueAssignee(ctx context.Context, issue *Issue, doer *user_model.Use
// Comment
comment, err = CreateCommentCtx(ctx, opts)
if err != nil {
- return false, nil, fmt.Errorf("createComment: %v", err)
+ return false, nil, fmt.Errorf("createComment: %w", err)
}
// if pull request is in the middle of creation - don't call webhook
diff --git a/models/issues/comment.go b/models/issues/comment.go
index 9ab6cab7d0..bdc574252c 100644
--- a/models/issues/comment.go
+++ b/models/issues/comment.go
@@ -573,13 +573,13 @@ func (c *Comment) UpdateAttachments(uuids []string) error {
attachments, err := repo_model.GetAttachmentsByUUIDs(ctx, uuids)
if err != nil {
- return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %v", uuids, err)
+ return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %w", uuids, err)
}
for i := 0; i < len(attachments); i++ {
attachments[i].IssueID = c.IssueID
attachments[i].CommentID = c.ID
if err := repo_model.UpdateAttachment(ctx, attachments[i]); err != nil {
- return fmt.Errorf("update attachment [id: %d]: %v", attachments[i].ID, err)
+ return fmt.Errorf("update attachment [id: %d]: %w", attachments[i].ID, err)
}
}
return committer.Commit()
@@ -874,7 +874,7 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment
// Check attachments
attachments, err := repo_model.GetAttachmentsByUUIDs(ctx, opts.Attachments)
if err != nil {
- return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %v", opts.Attachments, err)
+ return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %w", opts.Attachments, err)
}
for i := range attachments {
@@ -882,7 +882,7 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment
attachments[i].CommentID = comment.ID
// No assign value could be 0, so ignore AllCols().
if _, err = db.GetEngine(ctx).ID(attachments[i].ID).Update(attachments[i]); err != nil {
- return fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
+ return fmt.Errorf("update attachment [%d]: %w", attachments[i].ID, err)
}
}
case CommentTypeReopen, CommentTypeClose:
@@ -1034,7 +1034,7 @@ func CreateRefComment(doer *user_model.User, repo *repo_model.Repository, issue
CommitSHA: commitSHA,
})
if err != nil {
- return fmt.Errorf("check reference comment: %v", err)
+ return fmt.Errorf("check reference comment: %w", err)
} else if has {
return nil
}
@@ -1152,7 +1152,7 @@ func UpdateComment(c *Comment, doer *user_model.User) error {
return err
}
if err := committer.Commit(); err != nil {
- return fmt.Errorf("Commit: %v", err)
+ return fmt.Errorf("Commit: %w", err)
}
return nil
diff --git a/models/issues/issue.go b/models/issues/issue.go
index f77166db11..b1b140732b 100644
--- a/models/issues/issue.go
+++ b/models/issues/issue.go
@@ -196,7 +196,7 @@ func (issue *Issue) LoadRepo(ctx context.Context) (err error) {
if issue.Repo == nil {
issue.Repo, err = repo_model.GetRepositoryByIDCtx(ctx, issue.RepoID)
if err != nil {
- return fmt.Errorf("getRepositoryByID [%d]: %v", issue.RepoID, err)
+ return fmt.Errorf("getRepositoryByID [%d]: %w", issue.RepoID, err)
}
}
return nil
@@ -234,7 +234,7 @@ func (issue *Issue) LoadLabels(ctx context.Context) (err error) {
if issue.Labels == nil {
issue.Labels, err = GetLabelsByIssueID(ctx, issue.ID)
if err != nil {
- return fmt.Errorf("getLabelsByIssueID [%d]: %v", issue.ID, err)
+ return fmt.Errorf("getLabelsByIssueID [%d]: %w", issue.ID, err)
}
}
return nil
@@ -252,7 +252,7 @@ func (issue *Issue) loadPoster(ctx context.Context) (err error) {
issue.PosterID = -1
issue.Poster = user_model.NewGhostUser()
if !user_model.IsErrUserNotExist(err) {
- return fmt.Errorf("getUserByID.(poster) [%d]: %v", issue.PosterID, err)
+ return fmt.Errorf("getUserByID.(poster) [%d]: %w", issue.PosterID, err)
}
err = nil
return
@@ -268,7 +268,7 @@ func (issue *Issue) loadPullRequest(ctx context.Context) (err error) {
if IsErrPullRequestNotExist(err) {
return err
}
- return fmt.Errorf("getPullRequestByIssueID [%d]: %v", issue.ID, err)
+ return fmt.Errorf("getPullRequestByIssueID [%d]: %w", issue.ID, err)
}
issue.PullRequest.Issue = issue
}
@@ -361,7 +361,7 @@ func (issue *Issue) loadMilestone(ctx context.Context) (err error) {
if (issue.Milestone == nil || issue.Milestone.ID != issue.MilestoneID) && issue.MilestoneID > 0 {
issue.Milestone, err = GetMilestoneByRepoID(ctx, issue.RepoID, issue.MilestoneID)
if err != nil && !IsErrMilestoneNotExist(err) {
- return fmt.Errorf("getMilestoneByRepoID [repo_id: %d, milestone_id: %d]: %v", issue.RepoID, issue.MilestoneID, err)
+ return fmt.Errorf("getMilestoneByRepoID [repo_id: %d, milestone_id: %d]: %w", issue.RepoID, issue.MilestoneID, err)
}
}
return nil
@@ -401,7 +401,7 @@ func (issue *Issue) LoadAttributes(ctx context.Context) (err error) {
if issue.Attachments == nil {
issue.Attachments, err = repo_model.GetAttachmentsByIssueID(ctx, issue.ID)
if err != nil {
- return fmt.Errorf("getAttachmentsByIssueID [%d]: %v", issue.ID, err)
+ return fmt.Errorf("getAttachmentsByIssueID [%d]: %w", issue.ID, err)
}
}
@@ -518,19 +518,19 @@ func (issue *Issue) getLabels(ctx context.Context) (err error) {
issue.Labels, err = GetLabelsByIssueID(ctx, issue.ID)
if err != nil {
- return fmt.Errorf("getLabelsByIssueID: %v", err)
+ return fmt.Errorf("getLabelsByIssueID: %w", err)
}
return nil
}
func clearIssueLabels(ctx context.Context, issue *Issue, doer *user_model.User) (err error) {
if err = issue.getLabels(ctx); err != nil {
- return fmt.Errorf("getLabels: %v", err)
+ return fmt.Errorf("getLabels: %w", err)
}
for i := range issue.Labels {
if err = deleteIssueLabel(ctx, issue, issue.Labels[i], doer); err != nil {
- return fmt.Errorf("removeLabel: %v", err)
+ return fmt.Errorf("removeLabel: %w", err)
}
}
@@ -565,7 +565,7 @@ func ClearIssueLabels(issue *Issue, doer *user_model.User) (err error) {
}
if err = committer.Commit(); err != nil {
- return fmt.Errorf("Commit: %v", err)
+ return fmt.Errorf("Commit: %w", err)
}
return nil
@@ -635,13 +635,13 @@ func ReplaceIssueLabels(issue *Issue, labels []*Label, doer *user_model.User) (e
if len(toAdd) > 0 {
if err = newIssueLabels(ctx, issue, toAdd, doer); err != nil {
- return fmt.Errorf("addLabels: %v", err)
+ return fmt.Errorf("addLabels: %w", err)
}
}
for _, l := range toRemove {
if err = deleteIssueLabel(ctx, issue, l, doer); err != nil {
- return fmt.Errorf("removeLabel: %v", err)
+ return fmt.Errorf("removeLabel: %w", err)
}
}
@@ -766,11 +766,11 @@ func ChangeIssueTitle(issue *Issue, doer *user_model.User, oldTitle string) (err
defer committer.Close()
if err = UpdateIssueCols(ctx, issue, "name"); err != nil {
- return fmt.Errorf("updateIssueCols: %v", err)
+ return fmt.Errorf("updateIssueCols: %w", err)
}
if err = issue.LoadRepo(ctx); err != nil {
- return fmt.Errorf("loadRepo: %v", err)
+ return fmt.Errorf("loadRepo: %w", err)
}
opts := &CreateCommentOptions{
@@ -782,7 +782,7 @@ func ChangeIssueTitle(issue *Issue, doer *user_model.User, oldTitle string) (err
NewTitle: issue.Title,
}
if _, err = CreateCommentCtx(ctx, opts); err != nil {
- return fmt.Errorf("createComment: %v", err)
+ return fmt.Errorf("createComment: %w", err)
}
if err = issue.AddCrossReferences(ctx, doer, true); err != nil {
return err
@@ -800,11 +800,11 @@ func ChangeIssueRef(issue *Issue, doer *user_model.User, oldRef string) (err err
defer committer.Close()
if err = UpdateIssueCols(ctx, issue, "ref"); err != nil {
- return fmt.Errorf("updateIssueCols: %v", err)
+ return fmt.Errorf("updateIssueCols: %w", err)
}
if err = issue.LoadRepo(ctx); err != nil {
- return fmt.Errorf("loadRepo: %v", err)
+ return fmt.Errorf("loadRepo: %w", err)
}
oldRefFriendly := strings.TrimPrefix(oldRef, git.BranchPrefix)
newRefFriendly := strings.TrimPrefix(issue.Ref, git.BranchPrefix)
@@ -818,7 +818,7 @@ func ChangeIssueRef(issue *Issue, doer *user_model.User, oldRef string) (err err
NewRef: newRefFriendly,
}
if _, err = CreateCommentCtx(ctx, opts); err != nil {
- return fmt.Errorf("createComment: %v", err)
+ return fmt.Errorf("createComment: %w", err)
}
return committer.Commit()
@@ -850,12 +850,12 @@ func UpdateIssueAttachments(issueID int64, uuids []string) (err error) {
defer committer.Close()
attachments, err := repo_model.GetAttachmentsByUUIDs(ctx, uuids)
if err != nil {
- return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %v", uuids, err)
+ return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %w", uuids, err)
}
for i := 0; i < len(attachments); i++ {
attachments[i].IssueID = issueID
if err := repo_model.UpdateAttachment(ctx, attachments[i]); err != nil {
- return fmt.Errorf("update attachment [id: %d]: %v", attachments[i].ID, err)
+ return fmt.Errorf("update attachment [id: %d]: %w", attachments[i].ID, err)
}
}
return committer.Commit()
@@ -871,28 +871,28 @@ func ChangeIssueContent(issue *Issue, doer *user_model.User, content string) (er
hasContentHistory, err := HasIssueContentHistory(ctx, issue.ID, 0)
if err != nil {
- return fmt.Errorf("HasIssueContentHistory: %v", err)
+ return fmt.Errorf("HasIssueContentHistory: %w", err)
}
if !hasContentHistory {
if err = SaveIssueContentHistory(ctx, issue.PosterID, issue.ID, 0,
issue.CreatedUnix, issue.Content, true); err != nil {
- return fmt.Errorf("SaveIssueContentHistory: %v", err)
+ return fmt.Errorf("SaveIssueContentHistory: %w", err)
}
}
issue.Content = content
if err = UpdateIssueCols(ctx, issue, "content"); err != nil {
- return fmt.Errorf("UpdateIssueCols: %v", err)
+ return fmt.Errorf("UpdateIssueCols: %w", err)
}
if err = SaveIssueContentHistory(ctx, doer.ID, issue.ID, 0,
timeutil.TimeStampNow(), issue.Content, false); err != nil {
- return fmt.Errorf("SaveIssueContentHistory: %v", err)
+ return fmt.Errorf("SaveIssueContentHistory: %w", err)
}
if err = issue.AddCrossReferences(ctx, doer, true); err != nil {
- return fmt.Errorf("addCrossReferences: %v", err)
+ return fmt.Errorf("addCrossReferences: %w", err)
}
return committer.Commit()
@@ -969,7 +969,7 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
if opts.Issue.MilestoneID > 0 {
milestone, err := GetMilestoneByRepoID(ctx, opts.Issue.RepoID, opts.Issue.MilestoneID)
if err != nil && !IsErrMilestoneNotExist(err) {
- return fmt.Errorf("getMilestoneByID: %v", err)
+ return fmt.Errorf("getMilestoneByID: %w", err)
}
// Assume milestone is invalid and drop silently.
@@ -1023,7 +1023,7 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
// So we have to get all needed labels first.
labels := make([]*Label, 0, len(opts.LabelIDs))
if err = e.In("id", opts.LabelIDs).Find(&labels); err != nil {
- return fmt.Errorf("find all labels [label_ids: %v]: %v", opts.LabelIDs, err)
+ return fmt.Errorf("find all labels [label_ids: %v]: %w", opts.LabelIDs, err)
}
if err = opts.Issue.loadPoster(ctx); err != nil {
@@ -1037,7 +1037,7 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
}
if err = newIssueLabel(ctx, opts.Issue, label, opts.Issue.Poster); err != nil {
- return fmt.Errorf("addLabel [id: %d]: %v", label.ID, err)
+ return fmt.Errorf("addLabel [id: %d]: %w", label.ID, err)
}
}
}
@@ -1049,13 +1049,13 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
if len(opts.Attachments) > 0 {
attachments, err := repo_model.GetAttachmentsByUUIDs(ctx, opts.Attachments)
if err != nil {
- return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %v", opts.Attachments, err)
+ return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %w", opts.Attachments, err)
}
for i := 0; i < len(attachments); i++ {
attachments[i].IssueID = opts.Issue.ID
if _, err = e.ID(attachments[i].ID).Update(attachments[i]); err != nil {
- return fmt.Errorf("update attachment [id: %d]: %v", attachments[i].ID, err)
+ return fmt.Errorf("update attachment [id: %d]: %w", attachments[i].ID, err)
}
}
}
@@ -1090,11 +1090,11 @@ func NewIssue(repo *repo_model.Repository, issue *Issue, labelIDs []int64, uuids
if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) || IsErrNewIssueInsert(err) {
return err
}
- return fmt.Errorf("newIssue: %v", err)
+ return fmt.Errorf("newIssue: %w", err)
}
if err = committer.Commit(); err != nil {
- return fmt.Errorf("Commit: %v", err)
+ return fmt.Errorf("Commit: %w", err)
}
return nil
@@ -1614,7 +1614,7 @@ func UpdateIssueMentions(ctx context.Context, issueID int64, mentions []*user_mo
ids[i] = u.ID
}
if err := UpdateIssueUsersByMentions(ctx, issueID, ids); err != nil {
- return fmt.Errorf("UpdateIssueUsersByMentions: %v", err)
+ return fmt.Errorf("UpdateIssueUsersByMentions: %w", err)
}
return nil
}
@@ -1992,7 +1992,7 @@ func UpdateIssueByAPI(issue *Issue, doer *user_model.User) (statusChangeComment
defer committer.Close()
if err := issue.LoadRepo(ctx); err != nil {
- return nil, false, fmt.Errorf("loadRepo: %v", err)
+ return nil, false, fmt.Errorf("loadRepo: %w", err)
}
// Reload the issue
@@ -2020,7 +2020,7 @@ func UpdateIssueByAPI(issue *Issue, doer *user_model.User) (statusChangeComment
}
_, err := CreateCommentCtx(ctx, opts)
if err != nil {
- return nil, false, fmt.Errorf("createComment: %v", err)
+ return nil, false, fmt.Errorf("createComment: %w", err)
}
}
@@ -2056,7 +2056,7 @@ func UpdateIssueDeadline(issue *Issue, deadlineUnix timeutil.TimeStamp, doer *us
// Make the comment
if _, err = createDeadlineComment(ctx, doer, issue, deadlineUnix); err != nil {
- return fmt.Errorf("createRemovedDueDateComment: %v", err)
+ return fmt.Errorf("createRemovedDueDateComment: %w", err)
}
return committer.Commit()
@@ -2093,7 +2093,7 @@ func (issue *Issue) GetParticipantIDsByIssue(ctx context.Context) ([]int64, erro
Join("INNER", "`user`", "`user`.id = `comment`.poster_id").
Distinct("poster_id").
Find(&userIDs); err != nil {
- return nil, fmt.Errorf("get poster IDs: %v", err)
+ return nil, fmt.Errorf("get poster IDs: %w", err)
}
if !util.IsInt64InSlice(issue.PosterID, userIDs) {
return append(userIDs, issue.PosterID), nil
@@ -2151,10 +2151,10 @@ func FindAndUpdateIssueMentions(ctx context.Context, issue *Issue, doer *user_mo
rawMentions := references.FindAllMentionsMarkdown(content)
mentions, err = ResolveIssueMentionsByVisibility(ctx, issue, doer, rawMentions)
if err != nil {
- return nil, fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
+ return nil, fmt.Errorf("UpdateIssueMentions [%d]: %w", issue.ID, err)
}
if err = UpdateIssueMentions(ctx, issue.ID, mentions); err != nil {
- return nil, fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
+ return nil, fmt.Errorf("UpdateIssueMentions [%d]: %w", issue.ID, err)
}
return mentions, err
}
@@ -2206,7 +2206,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
Where("team_repo.repo_id=?", issue.Repo.ID).
In("team.lower_name", mentionTeams).
Find(&teams); err != nil {
- return nil, fmt.Errorf("find mentioned teams: %v", err)
+ return nil, fmt.Errorf("find mentioned teams: %w", err)
}
if len(teams) != 0 {
checked := make([]int64, 0, len(teams))
@@ -2222,7 +2222,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
}
has, err := db.GetEngine(ctx).Get(&organization.TeamUnit{OrgID: issue.Repo.Owner.ID, TeamID: team.ID, Type: unittype})
if err != nil {
- return nil, fmt.Errorf("get team units (%d): %v", team.ID, err)
+ return nil, fmt.Errorf("get team units (%d): %w", team.ID, err)
}
if has {
checked = append(checked, team.ID)
@@ -2237,7 +2237,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
And("`user`.is_active = ?", true).
And("`user`.prohibit_login = ?", false).
Find(&teamusers); err != nil {
- return nil, fmt.Errorf("get teams users: %v", err)
+ return nil, fmt.Errorf("get teams users: %w", err)
}
if len(teamusers) > 0 {
users = make([]*user_model.User, 0, len(teamusers))
@@ -2273,7 +2273,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
And("`user`.prohibit_login = ?", false).
In("`user`.lower_name", mentionUsers).
Find(&unchecked); err != nil {
- return nil, fmt.Errorf("find mentioned users: %v", err)
+ return nil, fmt.Errorf("find mentioned users: %w", err)
}
for _, user := range unchecked {
if already := resolved[user.LowerName]; already || user.IsOrganization() {
@@ -2282,7 +2282,7 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
// Normal users must have read access to the referencing issue
perm, err := access_model.GetUserRepoPermission(ctx, issue.Repo, user)
if err != nil {
- return nil, fmt.Errorf("GetUserRepoPermission [%d]: %v", user.ID, err)
+ return nil, fmt.Errorf("GetUserRepoPermission [%d]: %w", user.ID, err)
}
if !perm.CanReadIssuesOrPulls(issue.IsPull) {
continue
diff --git a/models/issues/issue_list.go b/models/issues/issue_list.go
index deadb6a564..bbe2292dd1 100644
--- a/models/issues/issue_list.go
+++ b/models/issues/issue_list.go
@@ -51,7 +51,7 @@ func (issues IssueList) loadRepositories(ctx context.Context) ([]*repo_model.Rep
In("id", repoIDs[:limit]).
Find(&repoMaps)
if err != nil {
- return nil, fmt.Errorf("find repository: %v", err)
+ return nil, fmt.Errorf("find repository: %w", err)
}
left -= limit
repoIDs = repoIDs[limit:]
@@ -161,7 +161,7 @@ func (issues IssueList) loadLabels(ctx context.Context) error {
err = rows.Scan(&labelIssue)
if err != nil {
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadLabels: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadLabels: Close: %w", err1)
}
return err
}
@@ -170,7 +170,7 @@ func (issues IssueList) loadLabels(ctx context.Context) error {
// When there are no rows left and we try to close it.
// Since that is not relevant for us, we can safely ignore it.
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadLabels: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadLabels: Close: %w", err1)
}
left -= limit
issueIDs = issueIDs[limit:]
@@ -287,7 +287,7 @@ func (issues IssueList) loadAssignees(ctx context.Context) error {
err = rows.Scan(&assigneeIssue)
if err != nil {
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadAssignees: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadAssignees: Close: %w", err1)
}
return err
}
@@ -295,7 +295,7 @@ func (issues IssueList) loadAssignees(ctx context.Context) error {
assignees[assigneeIssue.IssueAssignee.IssueID] = append(assignees[assigneeIssue.IssueAssignee.IssueID], assigneeIssue.Assignee)
}
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadAssignees: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadAssignees: Close: %w", err1)
}
left -= limit
issueIDs = issueIDs[limit:]
@@ -342,14 +342,14 @@ func (issues IssueList) loadPullRequests(ctx context.Context) error {
err = rows.Scan(&pr)
if err != nil {
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadPullRequests: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadPullRequests: Close: %w", err1)
}
return err
}
pullRequestMaps[pr.IssueID] = &pr
}
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadPullRequests: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadPullRequests: Close: %w", err1)
}
left -= limit
issuesIDs = issuesIDs[limit:]
@@ -387,14 +387,14 @@ func (issues IssueList) loadAttachments(ctx context.Context) (err error) {
err = rows.Scan(&attachment)
if err != nil {
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadAttachments: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadAttachments: Close: %w", err1)
}
return err
}
attachments[attachment.IssueID] = append(attachments[attachment.IssueID], &attachment)
}
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadAttachments: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadAttachments: Close: %w", err1)
}
left -= limit
issuesIDs = issuesIDs[limit:]
@@ -433,14 +433,14 @@ func (issues IssueList) loadComments(ctx context.Context, cond builder.Cond) (er
err = rows.Scan(&comment)
if err != nil {
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadComments: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadComments: Close: %w", err1)
}
return err
}
comments[comment.IssueID] = append(comments[comment.IssueID], &comment)
}
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadComments: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadComments: Close: %w", err1)
}
left -= limit
issuesIDs = issuesIDs[limit:]
@@ -492,14 +492,14 @@ func (issues IssueList) loadTotalTrackedTimes(ctx context.Context) (err error) {
err = rows.Scan(&totalTime)
if err != nil {
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadTotalTrackedTimes: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadTotalTrackedTimes: Close: %w", err1)
}
return err
}
trackedTimes[totalTime.IssueID] = totalTime.Time
}
if err1 := rows.Close(); err1 != nil {
- return fmt.Errorf("IssueList.loadTotalTrackedTimes: Close: %v", err1)
+ return fmt.Errorf("IssueList.loadTotalTrackedTimes: Close: %w", err1)
}
left -= limit
ids = ids[limit:]
@@ -514,35 +514,35 @@ func (issues IssueList) loadTotalTrackedTimes(ctx context.Context) (err error) {
// loadAttributes loads all attributes, expect for attachments and comments
func (issues IssueList) loadAttributes(ctx context.Context) error {
if _, err := issues.loadRepositories(ctx); err != nil {
- return fmt.Errorf("issue.loadAttributes: loadRepositories: %v", err)
+ return fmt.Errorf("issue.loadAttributes: loadRepositories: %w", err)
}
if err := issues.loadPosters(ctx); err != nil {
- return fmt.Errorf("issue.loadAttributes: loadPosters: %v", err)
+ return fmt.Errorf("issue.loadAttributes: loadPosters: %w", err)
}
if err := issues.loadLabels(ctx); err != nil {
- return fmt.Errorf("issue.loadAttributes: loadLabels: %v", err)
+ return fmt.Errorf("issue.loadAttributes: loadLabels: %w", err)
}
if err := issues.loadMilestones(ctx); err != nil {
- return fmt.Errorf("issue.loadAttributes: loadMilestones: %v", err)
+ return fmt.Errorf("issue.loadAttributes: loadMilestones: %w", err)
}
if err := issues.loadProjects(ctx); err != nil {
- return fmt.Errorf("issue.loadAttributes: loadProjects: %v", err)
+ return fmt.Errorf("issue.loadAttributes: loadProjects: %w", err)
}
if err := issues.loadAssignees(ctx); err != nil {
- return fmt.Errorf("issue.loadAttributes: loadAssignees: %v", err)
+ return fmt.Errorf("issue.loadAttributes: loadAssignees: %w", err)
}
if err := issues.loadPullRequests(ctx); err != nil {
- return fmt.Errorf("issue.loadAttributes: loadPullRequests: %v", err)
+ return fmt.Errorf("issue.loadAttributes: loadPullRequests: %w", err)
}
if err := issues.loadTotalTrackedTimes(ctx); err != nil {
- return fmt.Errorf("issue.loadAttributes: loadTotalTrackedTimes: %v", err)
+ return fmt.Errorf("issue.loadAttributes: loadTotalTrackedTimes: %w", err)
}
return nil
diff --git a/models/issues/issue_user.go b/models/issues/issue_user.go
index f5d22589af..c1a68c96e8 100644
--- a/models/issues/issue_user.go
+++ b/models/issues/issue_user.go
@@ -29,7 +29,7 @@ func init() {
func NewIssueUsers(ctx context.Context, repo *repo_model.Repository, issue *Issue) error {
assignees, err := repo_model.GetRepoAssignees(ctx, repo)
if err != nil {
- return fmt.Errorf("getAssignees: %v", err)
+ return fmt.Errorf("getAssignees: %w", err)
}
// Poster can be anyone, append later if not one of assignees.
diff --git a/models/issues/issue_xref.go b/models/issues/issue_xref.go
index 6de91058e8..e389f63d72 100644
--- a/models/issues/issue_xref.go
+++ b/models/issues/issue_xref.go
@@ -334,7 +334,7 @@ func (pr *PullRequest) ResolveCrossReferences(ctx context.Context) ([]*Comment,
In("ref_action", []references.XRefAction{references.XRefActionCloses, references.XRefActionReopens}).
OrderBy("id").
Find(&unfiltered); err != nil {
- return nil, fmt.Errorf("get reference: %v", err)
+ return nil, fmt.Errorf("get reference: %w", err)
}
refs := make([]*Comment, 0, len(unfiltered))
diff --git a/models/issues/label.go b/models/issues/label.go
index be97454e26..bbdc99e265 100644
--- a/models/issues/label.go
+++ b/models/issues/label.go
@@ -667,7 +667,7 @@ func newIssueLabels(ctx context.Context, issue *Issue, labels []*Label, doer *us
}
if err = newIssueLabel(ctx, issue, label, doer); err != nil {
- return fmt.Errorf("newIssueLabel: %v", err)
+ return fmt.Errorf("newIssueLabel: %w", err)
}
}
diff --git a/models/issues/pull.go b/models/issues/pull.go
index 18b67eb305..f03cabc3c8 100644
--- a/models/issues/pull.go
+++ b/models/issues/pull.go
@@ -228,7 +228,7 @@ func (pr *PullRequest) loadAttributes(ctx context.Context) (err error) {
pr.MergerID = -1
pr.Merger = user_model.NewGhostUser()
} else if err != nil {
- return fmt.Errorf("getUserByID [%d]: %v", pr.MergerID, err)
+ return fmt.Errorf("getUserByID [%d]: %w", pr.MergerID, err)
}
}
@@ -255,7 +255,7 @@ func (pr *PullRequest) LoadHeadRepoCtx(ctx context.Context) (err error) {
pr.HeadRepo, err = repo_model.GetRepositoryByIDCtx(ctx, pr.HeadRepoID)
if err != nil && !repo_model.IsErrRepoNotExist(err) { // Head repo maybe deleted, but it should still work
- return fmt.Errorf("getRepositoryByID(head): %v", err)
+ return fmt.Errorf("getRepositoryByID(head): %w", err)
}
pr.isHeadRepoLoaded = true
}
@@ -290,7 +290,7 @@ func (pr *PullRequest) LoadBaseRepoCtx(ctx context.Context) (err error) {
pr.BaseRepo, err = repo_model.GetRepositoryByIDCtx(ctx, pr.BaseRepoID)
if err != nil {
- return fmt.Errorf("repo_model.GetRepositoryByID(base): %v", err)
+ return fmt.Errorf("repo_model.GetRepositoryByID(base): %w", err)
}
return nil
}
@@ -482,7 +482,7 @@ func (pr *PullRequest) SetMerged(ctx context.Context) (bool, error) {
}
if _, err := changeIssueStatus(ctx, pr.Issue, pr.Merger, true, true); err != nil {
- return false, fmt.Errorf("Issue.changeStatus: %v", err)
+ return false, fmt.Errorf("Issue.changeStatus: %w", err)
}
// reset the conflicted files as there cannot be any if we're merged
@@ -490,7 +490,7 @@ func (pr *PullRequest) SetMerged(ctx context.Context) (bool, error) {
// We need to save all of the data used to compute this merge as it may have already been changed by TestPatch. FIXME: need to set some state to prevent TestPatch from running whilst we are merging.
if _, err := sess.Where("id = ?", pr.ID).Cols("has_merged, status, merge_base, merged_commit_id, merger_id, merged_unix, conflicted_files").Update(pr); err != nil {
- return false, fmt.Errorf("Failed to update pr[%d]: %v", pr.ID, err)
+ return false, fmt.Errorf("Failed to update pr[%d]: %w", pr.ID, err)
}
return true, nil
@@ -507,7 +507,7 @@ func NewPullRequest(outerCtx context.Context, repo *repo_model.Repository, issue
idx, err := db.GetNextResourceIndex(ctx, "issue_index", repo.ID)
if err != nil {
- return fmt.Errorf("generate pull request index failed: %v", err)
+ return fmt.Errorf("generate pull request index failed: %w", err)
}
issue.Index = idx
@@ -522,18 +522,18 @@ func NewPullRequest(outerCtx context.Context, repo *repo_model.Repository, issue
if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) || IsErrNewIssueInsert(err) {
return err
}
- return fmt.Errorf("newIssue: %v", err)
+ return fmt.Errorf("newIssue: %w", err)
}
pr.Index = issue.Index
pr.BaseRepo = repo
pr.IssueID = issue.ID
if err = db.Insert(ctx, pr); err != nil {
- return fmt.Errorf("insert pull repo: %v", err)
+ return fmt.Errorf("insert pull repo: %w", err)
}
if err = committer.Commit(); err != nil {
- return fmt.Errorf("Commit: %v", err)
+ return fmt.Errorf("Commit: %w", err)
}
return nil
diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go
index 8eeffa2c0d..c69f18492b 100644
--- a/models/issues/pull_list.go
+++ b/models/issues/pull_list.go
@@ -168,7 +168,7 @@ func (prs PullRequestList) loadAttributes(ctx context.Context) error {
Where("id > 0").
In("id", issueIDs).
Find(&issues); err != nil {
- return fmt.Errorf("find issues: %v", err)
+ return fmt.Errorf("find issues: %w", err)
}
set := make(map[int64]*Issue)
@@ -205,7 +205,7 @@ func (prs PullRequestList) InvalidateCodeComments(ctx context.Context, doer *use
Where("type = ? and invalidated = ?", CommentTypeCode, false).
In("issue_id", issueIDs).
Find(&codeComments); err != nil {
- return fmt.Errorf("find code comments: %v", err)
+ return fmt.Errorf("find code comments: %w", err)
}
for _, comment := range codeComments {
if err := comment.CheckInvalidation(repo, doer, branch); err != nil {
diff --git a/models/issues/reaction.go b/models/issues/reaction.go
index 02cffad3ba..c7503c23a2 100644
--- a/models/issues/reaction.go
+++ b/models/issues/reaction.go
@@ -355,7 +355,7 @@ func (list ReactionList) LoadUsers(ctx context.Context, repo *repo_model.Reposit
In("id", userIDs).
Find(&userMaps)
if err != nil {
- return nil, fmt.Errorf("find user: %v", err)
+ return nil, fmt.Errorf("find user: %w", err)
}
for _, reaction := range list {
diff --git a/models/issues/review.go b/models/issues/review.go
index 26fcea9eef..3d2fceda2d 100644
--- a/models/issues/review.go
+++ b/models/issues/review.go
@@ -790,10 +790,10 @@ func AddTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *user_
official, err := IsOfficialReviewerTeam(ctx, issue, reviewer)
if err != nil {
- return nil, fmt.Errorf("isOfficialReviewerTeam(): %v", err)
+ return nil, fmt.Errorf("isOfficialReviewerTeam(): %w", err)
} else if !official {
if official, err = IsOfficialReviewer(ctx, issue, doer); err != nil {
- return nil, fmt.Errorf("isOfficialReviewer(): %v", err)
+ return nil, fmt.Errorf("isOfficialReviewer(): %w", err)
}
}
@@ -823,7 +823,7 @@ func AddTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *user_
ReviewID: review.ID,
})
if err != nil {
- return nil, fmt.Errorf("CreateCommentCtx(): %v", err)
+ return nil, fmt.Errorf("CreateCommentCtx(): %w", err)
}
return comment, committer.Commit()
@@ -852,7 +852,7 @@ func RemoveTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *us
official, err := IsOfficialReviewerTeam(ctx, issue, reviewer)
if err != nil {
- return nil, fmt.Errorf("isOfficialReviewerTeam(): %v", err)
+ return nil, fmt.Errorf("isOfficialReviewerTeam(): %w", err)
}
if official {
@@ -882,7 +882,7 @@ func RemoveTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *us
AssigneeTeamID: reviewer.ID, // Use AssigneeTeamID as reviewer team ID
})
if err != nil {
- return nil, fmt.Errorf("CreateCommentCtx(): %v", err)
+ return nil, fmt.Errorf("CreateCommentCtx(): %w", err)
}
return comment, committer.Commit()