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 /models/perm | |
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 'models/perm')
-rw-r--r-- | models/perm/access/access.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/models/perm/access/access.go b/models/perm/access/access.go index 0e5e4ff2bb..7344e114a6 100644 --- a/models/perm/access/access.go +++ b/models/perm/access/access.go @@ -87,7 +87,7 @@ func updateUserAccess(accessMap map[int64]*userAccess, user *user_model.User, mo func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) { minMode := perm.AccessModeRead if err := repo.GetOwner(ctx); err != nil { - return fmt.Errorf("GetOwner: %v", err) + return fmt.Errorf("GetOwner: %w", err) } // If the repo isn't private and isn't owned by a organization, @@ -111,14 +111,14 @@ func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap // Delete old accesses and insert new ones for repository. if _, err = db.DeleteByBean(ctx, &Access{RepoID: repo.ID}); err != nil { - return fmt.Errorf("delete old accesses: %v", err) + return fmt.Errorf("delete old accesses: %w", err) } if len(newAccesses) == 0 { return nil } if err = db.Insert(ctx, newAccesses); err != nil { - return fmt.Errorf("insert new accesses: %v", err) + return fmt.Errorf("insert new accesses: %w", err) } return nil } @@ -127,7 +127,7 @@ func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap func refreshCollaboratorAccesses(ctx context.Context, repoID int64, accessMap map[int64]*userAccess) error { collaborators, err := repo_model.GetCollaborators(ctx, repoID, db.ListOptions{}) if err != nil { - return fmt.Errorf("getCollaborations: %v", err) + return fmt.Errorf("getCollaborations: %w", err) } for _, c := range collaborators { if c.User.IsGhost() { @@ -151,7 +151,7 @@ func RecalculateTeamAccesses(ctx context.Context, repo *repo_model.Repository, i } if err = refreshCollaboratorAccesses(ctx, repo.ID, accessMap); err != nil { - return fmt.Errorf("refreshCollaboratorAccesses: %v", err) + return fmt.Errorf("refreshCollaboratorAccesses: %w", err) } teams, err := organization.FindOrgTeams(ctx, repo.Owner.ID) @@ -173,7 +173,7 @@ func RecalculateTeamAccesses(ctx context.Context, repo *repo_model.Repository, i } if err = t.GetMembersCtx(ctx); err != nil { - return fmt.Errorf("getMembers '%d': %v", t.ID, err) + return fmt.Errorf("getMembers '%d': %w", t.ID, err) } for _, m := range t.Members { updateUserAccess(accessMap, m, t.AccessMode) @@ -224,10 +224,10 @@ func RecalculateUserAccess(ctx context.Context, repo *repo_model.Repository, uid // Delete old user accesses and insert new one for repository. if _, err = e.Delete(&Access{RepoID: repo.ID, UserID: uid}); err != nil { - return fmt.Errorf("delete old user accesses: %v", err) + return fmt.Errorf("delete old user accesses: %w", err) } else if accessMode >= minMode { if err = db.Insert(ctx, &Access{RepoID: repo.ID, UserID: uid, Mode: accessMode}); err != nil { - return fmt.Errorf("insert new user accesses: %v", err) + return fmt.Errorf("insert new user accesses: %w", err) } } return nil @@ -241,7 +241,7 @@ func RecalculateAccesses(ctx context.Context, repo *repo_model.Repository) error accessMap := make(map[int64]*userAccess, 20) if err := refreshCollaboratorAccesses(ctx, repo.ID, accessMap); err != nil { - return fmt.Errorf("refreshCollaboratorAccesses: %v", err) + return fmt.Errorf("refreshCollaboratorAccesses: %w", err) } return refreshAccesses(ctx, repo, accessMap) } |