diff options
author | Cheng <36215014+ChengenH@users.noreply.github.com> | 2024-04-22 03:44:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-21 19:44:03 +0000 |
commit | 9de443ced2c328d9b58a5e144a765f402aab859d (patch) | |
tree | 313cebffc92930047dce631db8c6597f0bcd0644 /models | |
parent | f95622cddc8db24719d10794e50ae6b125e6b96e (diff) | |
download | gitea-9de443ced2c328d9b58a5e144a765f402aab859d.tar.gz gitea-9de443ced2c328d9b58a5e144a765f402aab859d.zip |
chore: use errors.New to replace fmt.Errorf with no parameters will much better (#30621)
use errors.New to replace fmt.Errorf with no parameters will much better
Diffstat (limited to 'models')
-rw-r--r-- | models/auth/oauth2.go | 3 | ||||
-rw-r--r-- | models/git/lfs_lock.go | 4 | ||||
-rw-r--r-- | models/repo_transfer.go | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go index bc1bcaef63..7dca378e5d 100644 --- a/models/auth/oauth2.go +++ b/models/auth/oauth2.go @@ -8,6 +8,7 @@ import ( "crypto/sha256" "encoding/base32" "encoding/base64" + "errors" "fmt" "net" "net/url" @@ -294,7 +295,7 @@ func UpdateOAuth2Application(ctx context.Context, opts UpdateOAuth2ApplicationOp return nil, err } if app.UID != opts.UserID { - return nil, fmt.Errorf("UID mismatch") + return nil, errors.New("UID mismatch") } builtinApps := BuiltinApplications() if _, builtin := builtinApps[app.ClientID]; builtin { diff --git a/models/git/lfs_lock.go b/models/git/lfs_lock.go index 261c73032a..2f65833fe3 100644 --- a/models/git/lfs_lock.go +++ b/models/git/lfs_lock.go @@ -5,7 +5,7 @@ package git import ( "context" - "fmt" + "errors" "strings" "time" @@ -148,7 +148,7 @@ func DeleteLFSLockByID(ctx context.Context, id int64, repo *repo_model.Repositor } if !force && u.ID != lock.OwnerID { - return nil, fmt.Errorf("user doesn't own lock and force flag is not set") + return nil, errors.New("user doesn't own lock and force flag is not set") } if _, err := db.GetEngine(dbCtx).ID(id).Delete(new(LFSLock)); err != nil { diff --git a/models/repo_transfer.go b/models/repo_transfer.go index 747ec2f248..37f591f65d 100644 --- a/models/repo_transfer.go +++ b/models/repo_transfer.go @@ -5,6 +5,7 @@ package models import ( "context" + "errors" "fmt" "code.gitea.io/gitea/models/db" @@ -147,7 +148,7 @@ func DeleteRepositoryTransfer(ctx context.Context, repoID int64) error { func TestRepositoryReadyForTransfer(status repo_model.RepositoryStatus) error { switch status { case repo_model.RepositoryBeingMigrated: - return fmt.Errorf("repo is not ready, currently migrating") + return errors.New("repo is not ready, currently migrating") case repo_model.RepositoryPendingTransfer: return ErrRepoTransferInProgress{} } |