summaryrefslogtreecommitdiffstats
path: root/models/activities
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/activities
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/activities')
-rw-r--r--models/activities/action.go16
-rw-r--r--models/activities/action_list.go4
-rw-r--r--models/activities/notification.go6
-rw-r--r--models/activities/repo_activity.go16
4 files changed, 21 insertions, 21 deletions
diff --git a/models/activities/action.go b/models/activities/action.go
index 3c8acb5ba8..147511edec 100644
--- a/models/activities/action.go
+++ b/models/activities/action.go
@@ -359,11 +359,11 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, error) {
actions := make([]*Action, 0, opts.PageSize)
if err := sess.Desc("`action`.created_unix").Find(&actions); err != nil {
- return nil, fmt.Errorf("Find: %v", err)
+ return nil, fmt.Errorf("Find: %w", err)
}
if err := ActionList(actions).loadAttributes(ctx); err != nil {
- return nil, fmt.Errorf("LoadAttributes: %v", err)
+ return nil, fmt.Errorf("LoadAttributes: %w", err)
}
return actions, nil
@@ -415,7 +415,7 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
env := organization.OrgFromUser(opts.RequestedUser).AccessibleTeamReposEnv(opts.RequestedTeam)
teamRepoIDs, err := env.RepoIDs(1, opts.RequestedUser.NumRepos)
if err != nil {
- return nil, fmt.Errorf("GetTeamRepositories: %v", err)
+ return nil, fmt.Errorf("GetTeamRepositories: %w", err)
}
cond = cond.And(builder.In("repo_id", teamRepoIDs))
}
@@ -477,14 +477,14 @@ func notifyWatchers(ctx context.Context, actions ...*Action) error {
// Add feeds for user self and all watchers.
watchers, err = repo_model.GetWatchers(ctx, act.RepoID)
if err != nil {
- return fmt.Errorf("get watchers: %v", err)
+ return fmt.Errorf("get watchers: %w", err)
}
}
// Add feed for actioner.
act.UserID = act.ActUserID
if _, err = e.Insert(act); err != nil {
- return fmt.Errorf("insert new actioner: %v", err)
+ return fmt.Errorf("insert new actioner: %w", err)
}
if repoChanged {
@@ -493,7 +493,7 @@ func notifyWatchers(ctx context.Context, actions ...*Action) error {
// check repo owner exist.
if err := act.Repo.GetOwner(ctx); err != nil {
- return fmt.Errorf("can't get repo owner: %v", err)
+ return fmt.Errorf("can't get repo owner: %w", err)
}
} else if act.Repo == nil {
act.Repo = repo
@@ -504,7 +504,7 @@ func notifyWatchers(ctx context.Context, actions ...*Action) error {
act.ID = 0
act.UserID = act.Repo.Owner.ID
if err = db.Insert(ctx, act); err != nil {
- return fmt.Errorf("insert new actioner: %v", err)
+ return fmt.Errorf("insert new actioner: %w", err)
}
}
@@ -557,7 +557,7 @@ func notifyWatchers(ctx context.Context, actions ...*Action) error {
}
if err = db.Insert(ctx, act); err != nil {
- return fmt.Errorf("insert new action: %v", err)
+ return fmt.Errorf("insert new action: %w", err)
}
}
}
diff --git a/models/activities/action_list.go b/models/activities/action_list.go
index f349b94ac8..86aa8689e2 100644
--- a/models/activities/action_list.go
+++ b/models/activities/action_list.go
@@ -36,7 +36,7 @@ func (actions ActionList) loadUsers(ctx context.Context) (map[int64]*user_model.
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 _, action := range actions {
@@ -62,7 +62,7 @@ func (actions ActionList) loadRepositories(ctx context.Context) error {
repoMaps := make(map[int64]*repo_model.Repository, len(repoIDs))
err := db.GetEngine(ctx).In("id", repoIDs).Find(&repoMaps)
if err != nil {
- return fmt.Errorf("find repository: %v", err)
+ return fmt.Errorf("find repository: %w", err)
}
for _, action := range actions {
diff --git a/models/activities/notification.go b/models/activities/notification.go
index 0a61088167..5748b807a0 100644
--- a/models/activities/notification.go
+++ b/models/activities/notification.go
@@ -403,7 +403,7 @@ func (n *Notification) loadRepo(ctx context.Context) (err error) {
if n.Repository == nil {
n.Repository, err = repo_model.GetRepositoryByIDCtx(ctx, n.RepoID)
if err != nil {
- return fmt.Errorf("getRepositoryByID [%d]: %v", n.RepoID, err)
+ return fmt.Errorf("getRepositoryByID [%d]: %w", n.RepoID, err)
}
}
return nil
@@ -413,7 +413,7 @@ func (n *Notification) loadIssue(ctx context.Context) (err error) {
if n.Issue == nil && n.IssueID != 0 {
n.Issue, err = issues_model.GetIssueByID(ctx, n.IssueID)
if err != nil {
- return fmt.Errorf("getIssueByID [%d]: %v", n.IssueID, err)
+ return fmt.Errorf("getIssueByID [%d]: %w", n.IssueID, err)
}
return n.Issue.LoadAttributes(ctx)
}
@@ -440,7 +440,7 @@ func (n *Notification) loadUser(ctx context.Context) (err error) {
if n.User == nil {
n.User, err = user_model.GetUserByIDCtx(ctx, n.UserID)
if err != nil {
- return fmt.Errorf("getUserByID [%d]: %v", n.UserID, err)
+ return fmt.Errorf("getUserByID [%d]: %w", n.UserID, err)
}
}
return nil
diff --git a/models/activities/repo_activity.go b/models/activities/repo_activity.go
index 3052d65e83..4c8aa7e81d 100644
--- a/models/activities/repo_activity.go
+++ b/models/activities/repo_activity.go
@@ -49,32 +49,32 @@ func GetActivityStats(ctx context.Context, repo *repo_model.Repository, timeFrom
stats := &ActivityStats{Code: &git.CodeActivityStats{}}
if releases {
if err := stats.FillReleases(repo.ID, timeFrom); err != nil {
- return nil, fmt.Errorf("FillReleases: %v", err)
+ return nil, fmt.Errorf("FillReleases: %w", err)
}
}
if prs {
if err := stats.FillPullRequests(repo.ID, timeFrom); err != nil {
- return nil, fmt.Errorf("FillPullRequests: %v", err)
+ return nil, fmt.Errorf("FillPullRequests: %w", err)
}
}
if issues {
if err := stats.FillIssues(repo.ID, timeFrom); err != nil {
- return nil, fmt.Errorf("FillIssues: %v", err)
+ return nil, fmt.Errorf("FillIssues: %w", err)
}
}
if err := stats.FillUnresolvedIssues(repo.ID, timeFrom, issues, prs); err != nil {
- return nil, fmt.Errorf("FillUnresolvedIssues: %v", err)
+ return nil, fmt.Errorf("FillUnresolvedIssues: %w", err)
}
if code {
gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath())
if err != nil {
- return nil, fmt.Errorf("OpenRepository: %v", err)
+ return nil, fmt.Errorf("OpenRepository: %w", err)
}
defer closer.Close()
code, err := gitRepo.GetCodeActivityStats(timeFrom, repo.DefaultBranch)
if err != nil {
- return nil, fmt.Errorf("FillFromGit: %v", err)
+ return nil, fmt.Errorf("FillFromGit: %w", err)
}
stats.Code = code
}
@@ -85,13 +85,13 @@ func GetActivityStats(ctx context.Context, repo *repo_model.Repository, timeFrom
func GetActivityStatsTopAuthors(ctx context.Context, repo *repo_model.Repository, timeFrom time.Time, count int) ([]*ActivityAuthorData, error) {
gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath())
if err != nil {
- return nil, fmt.Errorf("OpenRepository: %v", err)
+ return nil, fmt.Errorf("OpenRepository: %w", err)
}
defer closer.Close()
code, err := gitRepo.GetCodeActivityStats(timeFrom, "")
if err != nil {
- return nil, fmt.Errorf("FillFromGit: %v", err)
+ return nil, fmt.Errorf("FillFromGit: %w", err)
}
if code.Authors == nil {
return nil, nil