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/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 'models/migrations')
45 files changed, 77 insertions, 77 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index a6201c1090..f1f943a2c2 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -428,13 +428,13 @@ var migrations = []Migration{ // GetCurrentDBVersion returns the current db version func GetCurrentDBVersion(x *xorm.Engine) (int64, error) { if err := x.Sync(new(Version)); err != nil { - return -1, fmt.Errorf("sync: %v", err) + return -1, fmt.Errorf("sync: %w", err) } currentVersion := &Version{ID: 1} has, err := x.Get(currentVersion) if err != nil { - return -1, fmt.Errorf("get: %v", err) + return -1, fmt.Errorf("get: %w", err) } if !has { return -1, nil @@ -476,13 +476,13 @@ func Migrate(x *xorm.Engine) error { // Set a new clean the default mapper to GonicMapper as that is the default for Gitea. x.SetMapper(names.GonicMapper{}) if err := x.Sync(new(Version)); err != nil { - return fmt.Errorf("sync: %v", err) + return fmt.Errorf("sync: %w", err) } currentVersion := &Version{ID: 1} has, err := x.Get(currentVersion) if err != nil { - return fmt.Errorf("get: %v", err) + return fmt.Errorf("get: %w", err) } else if !has { // If the version record does not exist we think // it is a fresh installation and we can skip all migrations. @@ -490,7 +490,7 @@ func Migrate(x *xorm.Engine) error { currentVersion.Version = int64(minDBVersion + len(migrations)) if _, err = x.InsertOne(currentVersion); err != nil { - return fmt.Errorf("insert: %v", err) + return fmt.Errorf("insert: %w", err) } } @@ -519,7 +519,7 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t // Reset the mapper between each migration - migrations are not supposed to depend on each other x.SetMapper(names.GonicMapper{}) if err = m.Migrate(x); err != nil { - return fmt.Errorf("migration[%d]: %s failed: %v", v+int64(i), m.Description(), err) + return fmt.Errorf("migration[%d]: %s failed: %w", v+int64(i), m.Description(), err) } currentVersion.Version = v + int64(i) + 1 if _, err = x.ID(1).Update(currentVersion); err != nil { @@ -918,7 +918,7 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin cols += "DROP COLUMN `" + col + "` CASCADE" } if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil { - return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) + return fmt.Errorf("Drop table `%s` columns %v: %w", tableName, columnNames, err) } case setting.Database.UseMySQL: // Drop indexes on columns first @@ -946,7 +946,7 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin cols += "DROP COLUMN `" + col + "`" } if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil { - return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) + return fmt.Errorf("Drop table `%s` columns %v: %w", tableName, columnNames, err) } case setting.Database.UseMSSQL: cols := "" @@ -960,27 +960,27 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin tableName, strings.ReplaceAll(cols, "`", "'")) constraints := make([]string, 0) if err := sess.SQL(sql).Find(&constraints); err != nil { - return fmt.Errorf("Find constraints: %v", err) + return fmt.Errorf("Find constraints: %w", err) } for _, constraint := range constraints { if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP CONSTRAINT `%s`", tableName, constraint)); err != nil { - return fmt.Errorf("Drop table `%s` default constraint `%s`: %v", tableName, constraint, err) + return fmt.Errorf("Drop table `%s` default constraint `%s`: %w", tableName, constraint, err) } } sql = fmt.Sprintf("SELECT DISTINCT Name FROM sys.indexes INNER JOIN sys.index_columns ON indexes.index_id = index_columns.index_id AND indexes.object_id = index_columns.object_id WHERE indexes.object_id = OBJECT_ID('%[1]s') AND index_columns.column_id IN (SELECT column_id FROM sys.columns WHERE LOWER(name) IN (%[2]s) AND object_id = OBJECT_ID('%[1]s'))", tableName, strings.ReplaceAll(cols, "`", "'")) constraints = make([]string, 0) if err := sess.SQL(sql).Find(&constraints); err != nil { - return fmt.Errorf("Find constraints: %v", err) + return fmt.Errorf("Find constraints: %w", err) } for _, constraint := range constraints { if _, err := sess.Exec(fmt.Sprintf("DROP INDEX `%[2]s` ON `%[1]s`", tableName, constraint)); err != nil { - return fmt.Errorf("Drop index `%[2]s` on `%[1]s`: %v", tableName, constraint, err) + return fmt.Errorf("Drop index `%s` on `%s`: %w", constraint, tableName, err) } } if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP COLUMN %s", tableName, cols)); err != nil { - return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) + return fmt.Errorf("Drop table `%s` columns %v: %w", tableName, columnNames, err) } default: log.Fatal("Unrecognized DB") diff --git a/models/migrations/v113.go b/models/migrations/v113.go index 199c02ac98..4af246863d 100644 --- a/models/migrations/v113.go +++ b/models/migrations/v113.go @@ -17,7 +17,7 @@ func featureChangeTargetBranch(x *xorm.Engine) error { } if err := x.Sync2(new(Comment)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v115.go b/models/migrations/v115.go index b242ccf238..3e61cb6e0e 100644 --- a/models/migrations/v115.go +++ b/models/migrations/v115.go @@ -45,11 +45,11 @@ func renameExistingUserAvatarName(x *xorm.Engine) error { migrated := 0 for { if err := sess.Begin(); err != nil { - return fmt.Errorf("session.Begin: %v", err) + return fmt.Errorf("session.Begin: %w", err) } users := make([]*User, 0, 50) if err := sess.Table("user").Asc("id").Limit(50, start).Find(&users); err != nil { - return fmt.Errorf("select users from id [%d]: %v", start, err) + return fmt.Errorf("select users from id [%d]: %w", start, err) } if len(users) == 0 { _ = sess.Rollback() @@ -76,7 +76,7 @@ func renameExistingUserAvatarName(x *xorm.Engine) error { newAvatar, err := copyOldAvatarToNewLocation(user.ID, oldAvatar) if err != nil { _ = sess.Rollback() - return fmt.Errorf("[user: %s] %v", user.LowerName, err) + return fmt.Errorf("[user: %s] %w", user.LowerName, err) } else if newAvatar == oldAvatar { continue } @@ -84,7 +84,7 @@ func renameExistingUserAvatarName(x *xorm.Engine) error { user.Avatar = newAvatar if _, err := sess.ID(user.ID).Cols("avatar").Update(user); err != nil { _ = sess.Rollback() - return fmt.Errorf("[user: %s] user table update: %v", user.LowerName, err) + return fmt.Errorf("[user: %s] user table update: %w", user.LowerName, err) } deleteList.Add(filepath.Join(setting.Avatar.Path, oldAvatar)) @@ -104,7 +104,7 @@ func renameExistingUserAvatarName(x *xorm.Engine) error { } if err := sess.Commit(); err != nil { _ = sess.Rollback() - return fmt.Errorf("commit session: %v", err) + return fmt.Errorf("commit session: %w", err) } } @@ -138,13 +138,13 @@ func renameExistingUserAvatarName(x *xorm.Engine) error { func copyOldAvatarToNewLocation(userID int64, oldAvatar string) (string, error) { fr, err := os.Open(filepath.Join(setting.Avatar.Path, oldAvatar)) if err != nil { - return "", fmt.Errorf("os.Open: %v", err) + return "", fmt.Errorf("os.Open: %w", err) } defer fr.Close() data, err := io.ReadAll(fr) if err != nil { - return "", fmt.Errorf("io.ReadAll: %v", err) + return "", fmt.Errorf("io.ReadAll: %w", err) } newAvatar := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%d-%x", userID, md5.Sum(data))))) @@ -153,7 +153,7 @@ func copyOldAvatarToNewLocation(userID int64, oldAvatar string) (string, error) } if err := os.WriteFile(filepath.Join(setting.Avatar.Path, newAvatar), data, 0o666); err != nil { - return "", fmt.Errorf("os.WriteFile: %v", err) + return "", fmt.Errorf("os.WriteFile: %w", err) } return newAvatar, nil diff --git a/models/migrations/v125.go b/models/migrations/v125.go index ac567f66b9..64483e1397 100644 --- a/models/migrations/v125.go +++ b/models/migrations/v125.go @@ -17,7 +17,7 @@ func addReviewMigrateInfo(x *xorm.Engine) error { } if err := x.Sync2(new(Review)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v127.go b/models/migrations/v127.go index d8f0de4a6e..7be1e326d4 100644 --- a/models/migrations/v127.go +++ b/models/migrations/v127.go @@ -36,10 +36,10 @@ func addLanguageStats(x *xorm.Engine) error { } if err := x.Sync2(new(LanguageStat)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } if err := x.Sync2(new(RepoIndexerStatus)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v128.go b/models/migrations/v128.go index aba0ed6897..7e84ff5b71 100644 --- a/models/migrations/v128.go +++ b/models/migrations/v128.go @@ -59,7 +59,7 @@ func fixMergeBase(x *xorm.Engine) error { for { prs := make([]PullRequest, 0, 50) if err := x.Limit(limit, start).Asc("id").Find(&prs); err != nil { - return fmt.Errorf("Find: %v", err) + return fmt.Errorf("Find: %w", err) } if len(prs) == 0 { break @@ -70,7 +70,7 @@ func fixMergeBase(x *xorm.Engine) error { baseRepo := &Repository{ID: pr.BaseRepoID} has, err := x.Table("repository").Get(baseRepo) if err != nil { - return fmt.Errorf("Unable to get base repo %d %v", pr.BaseRepoID, err) + return fmt.Errorf("Unable to get base repo %d %w", pr.BaseRepoID, err) } if !has { log.Error("Missing base repo with id %d for PR ID %d", pr.BaseRepoID, pr.ID) diff --git a/models/migrations/v131.go b/models/migrations/v131.go index a38c7be634..48fd3e29c9 100644 --- a/models/migrations/v131.go +++ b/models/migrations/v131.go @@ -16,7 +16,7 @@ func addSystemWebhookColumn(x *xorm.Engine) error { } if err := x.Sync2(new(Webhook)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v132.go b/models/migrations/v132.go index 3f7b1c9709..e67a67e907 100644 --- a/models/migrations/v132.go +++ b/models/migrations/v132.go @@ -16,7 +16,7 @@ func addBranchProtectionProtectedFilesColumn(x *xorm.Engine) error { } if err := x.Sync2(new(ProtectedBranch)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v134.go b/models/migrations/v134.go index 06d0f8276a..75c6768720 100644 --- a/models/migrations/v134.go +++ b/models/migrations/v134.go @@ -58,7 +58,7 @@ func refixMergeBase(x *xorm.Engine) error { for { prs := make([]PullRequest, 0, 50) if err := x.Limit(limit, start).Asc("id").Where("has_merged = ?", true).Find(&prs); err != nil { - return fmt.Errorf("Find: %v", err) + return fmt.Errorf("Find: %w", err) } if len(prs) == 0 { break @@ -69,7 +69,7 @@ func refixMergeBase(x *xorm.Engine) error { baseRepo := &Repository{ID: pr.BaseRepoID} has, err := x.Table("repository").Get(baseRepo) if err != nil { - return fmt.Errorf("Unable to get base repo %d %v", pr.BaseRepoID, err) + return fmt.Errorf("Unable to get base repo %d %w", pr.BaseRepoID, err) } if !has { log.Error("Missing base repo with id %d for PR ID %d", pr.BaseRepoID, pr.ID) diff --git a/models/migrations/v135.go b/models/migrations/v135.go index 8d859d42c0..eaa852d44f 100644 --- a/models/migrations/v135.go +++ b/models/migrations/v135.go @@ -16,7 +16,7 @@ func addOrgIDLabelColumn(x *xorm.Engine) error { } if err := x.Sync2(new(Label)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v136.go b/models/migrations/v136.go index 94372e4142..b2192f3853 100644 --- a/models/migrations/v136.go +++ b/models/migrations/v136.go @@ -44,7 +44,7 @@ func addCommitDivergenceToPulls(x *xorm.Engine) error { } if err := x.Sync2(new(PullRequest)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } last := 0 @@ -80,7 +80,7 @@ func addCommitDivergenceToPulls(x *xorm.Engine) error { baseRepo := &Repository{ID: pr.BaseRepoID} has, err := x.Table("repository").Get(baseRepo) if err != nil { - return fmt.Errorf("Unable to get base repo %d %v", pr.BaseRepoID, err) + return fmt.Errorf("Unable to get base repo %d %w", pr.BaseRepoID, err) } if !has { log.Error("Missing base repo with id %d for PR ID %d", pr.BaseRepoID, pr.ID) @@ -101,7 +101,7 @@ func addCommitDivergenceToPulls(x *xorm.Engine) error { pr.CommitsBehind = divergence.Behind if _, err = sess.ID(pr.ID).Cols("commits_ahead", "commits_behind").Update(pr); err != nil { - return fmt.Errorf("Update Cols: %v", err) + return fmt.Errorf("Update Cols: %w", err) } migrated++ } diff --git a/models/migrations/v138.go b/models/migrations/v138.go index 2db9b821ad..03235200ab 100644 --- a/models/migrations/v138.go +++ b/models/migrations/v138.go @@ -16,7 +16,7 @@ func addResolveDoerIDCommentColumn(x *xorm.Engine) error { } if err := x.Sync2(new(Comment)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v140.go b/models/migrations/v140.go index 871d14b84e..b54740f1a9 100644 --- a/models/migrations/v140.go +++ b/models/migrations/v140.go @@ -34,7 +34,7 @@ func fixLanguageStatsToSaveSize(x *xorm.Engine) error { } if err := x.Sync2(new(LanguageStat)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } x.Delete(&RepoIndexerStatus{IndexerType: RepoIndexerTypeStats}) diff --git a/models/migrations/v141.go b/models/migrations/v141.go index ab05698b8c..21247cc78f 100644 --- a/models/migrations/v141.go +++ b/models/migrations/v141.go @@ -16,7 +16,7 @@ func addKeepActivityPrivateUserColumn(x *xorm.Engine) error { } if err := x.Sync2(new(User)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v145.go b/models/migrations/v145.go index ee79c20e97..afc60497e3 100644 --- a/models/migrations/v145.go +++ b/models/migrations/v145.go @@ -53,16 +53,16 @@ func increaseLanguageField(x *xorm.Engine) error { if err := sess.SQL(`SELECT i.name AS Name FROM sys.indexes i INNER JOIN sys.index_columns ic ON i.index_id = ic.index_id AND i.object_id = ic.object_id - INNER JOIN sys.tables AS t + INNER JOIN sys.tables AS t ON t.object_id = i.object_id INNER JOIN sys.columns c ON t.object_id = c.object_id AND ic.column_id = c.column_id WHERE t.name = 'language_stat' AND c.name = 'language'`).Find(&constraints); err != nil { - return fmt.Errorf("Find constraints: %v", err) + return fmt.Errorf("Find constraints: %w", err) } for _, constraint := range constraints { if _, err := sess.Exec(fmt.Sprintf("DROP INDEX [%s] ON `language_stat`", constraint)); err != nil { - return fmt.Errorf("Drop table `language_stat` constraint `%s`: %v", constraint, err) + return fmt.Errorf("Drop table `language_stat` constraint `%s`: %w", constraint, err) } } if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat ALTER COLUMN language %s", sqlType)); err != nil { diff --git a/models/migrations/v149.go b/models/migrations/v149.go index 60c0fae8bc..4d2cf5b976 100644 --- a/models/migrations/v149.go +++ b/models/migrations/v149.go @@ -19,7 +19,7 @@ func addCreatedAndUpdatedToMilestones(x *xorm.Engine) error { } if err := x.Sync2(new(Milestone)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v155.go b/models/migrations/v155.go index 58d78b6cfb..f95b4dfa3f 100644 --- a/models/migrations/v155.go +++ b/models/migrations/v155.go @@ -16,7 +16,7 @@ func addChangedProtectedFilesPullRequestColumn(x *xorm.Engine) error { } if err := x.Sync2(new(PullRequest)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v156.go b/models/migrations/v156.go index 26f97fe984..2c146892d2 100644 --- a/models/migrations/v156.go +++ b/models/migrations/v156.go @@ -123,7 +123,7 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error { continue } log.Error("Error whilst getting commit for Tag: %s in [%d]%s/%s. Error: %v", release.TagName, repo.ID, repo.OwnerName, repo.Name, err) - return fmt.Errorf("GetTagCommit: %v", err) + return fmt.Errorf("GetTagCommit: %w", err) } if commit.Author.Email == "" { @@ -135,7 +135,7 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error { continue } log.Error("Error whilst getting commit for Tag: %s in [%d]%s/%s. Error: %v", release.TagName, repo.ID, repo.OwnerName, repo.Name, err) - return fmt.Errorf("GetCommit: %v", err) + return fmt.Errorf("GetCommit: %w", err) } } diff --git a/models/migrations/v164.go b/models/migrations/v164.go index 01ba796563..02343fac24 100644 --- a/models/migrations/v164.go +++ b/models/migrations/v164.go @@ -32,7 +32,7 @@ func (grant *OAuth2Grant) TableName() string { func addScopeAndNonceColumnsToOAuth2Grant(x *xorm.Engine) error { if err := x.Sync2(new(OAuth2Grant)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v167.go b/models/migrations/v167.go index fd91f226ab..26d7cfd4f8 100644 --- a/models/migrations/v167.go +++ b/models/migrations/v167.go @@ -18,7 +18,7 @@ func addUserRedirect(x *xorm.Engine) (err error) { } if err := x.Sync2(new(UserRedirect)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v170.go b/models/migrations/v170.go index 853a23d290..2d654fb2b1 100644 --- a/models/migrations/v170.go +++ b/models/migrations/v170.go @@ -16,7 +16,7 @@ func addDismissedReviewColumn(x *xorm.Engine) error { } if err := x.Sync2(new(Review)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v171.go b/models/migrations/v171.go index 2547ff0f77..8b27493cea 100644 --- a/models/migrations/v171.go +++ b/models/migrations/v171.go @@ -16,7 +16,7 @@ func addSortingColToProjectBoard(x *xorm.Engine) error { } if err := x.Sync2(new(ProjectBoard)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v173.go b/models/migrations/v173.go index dd4589066d..c1f167e6f6 100644 --- a/models/migrations/v173.go +++ b/models/migrations/v173.go @@ -16,7 +16,7 @@ func addTimeIDCommentColumn(x *xorm.Engine) error { } if err := x.Sync2(new(Comment)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v174.go b/models/migrations/v174.go index 5915d3626b..b6c555525e 100644 --- a/models/migrations/v174.go +++ b/models/migrations/v174.go @@ -28,7 +28,7 @@ func addRepoTransfer(x *xorm.Engine) error { } if err := sess.Sync2(new(RepoTransfer)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return sess.Commit() diff --git a/models/migrations/v177.go b/models/migrations/v177.go index c65fd3de00..f28826f170 100644 --- a/models/migrations/v177.go +++ b/models/migrations/v177.go @@ -25,7 +25,7 @@ func deleteOrphanedIssueLabels(x *xorm.Engine) error { } if err := sess.Sync2(new(IssueLabel)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } if _, err := sess.Exec(`DELETE FROM issue_label WHERE issue_label.id IN ( diff --git a/models/migrations/v183.go b/models/migrations/v183.go index cc752bf827..0dc3af28a7 100644 --- a/models/migrations/v183.go +++ b/models/migrations/v183.go @@ -32,7 +32,7 @@ func createPushMirrorTable(x *xorm.Engine) error { } if err := sess.Sync2(new(PushMirror)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return sess.Commit() diff --git a/models/migrations/v184.go b/models/migrations/v184.go index 97bc72d5d9..593a8100a8 100644 --- a/models/migrations/v184.go +++ b/models/migrations/v184.go @@ -43,7 +43,7 @@ func renameTaskErrorsToMessage(x *xorm.Engine) error { } if err := sess.Sync2(new(Task)); err != nil { - return fmt.Errorf("error on Sync2: %v", err) + return fmt.Errorf("error on Sync2: %w", err) } if messageExist { diff --git a/models/migrations/v190.go b/models/migrations/v190.go index 8d1fba8373..00046ff2a1 100644 --- a/models/migrations/v190.go +++ b/models/migrations/v190.go @@ -18,7 +18,7 @@ func addAgitFlowPullRequest(x *xorm.Engine) error { } if err := x.Sync2(new(PullRequest)); err != nil { - return fmt.Errorf("sync2: %v", err) + return fmt.Errorf("sync2: %w", err) } return nil } diff --git a/models/migrations/v194.go b/models/migrations/v194.go index 7ea160e2b2..6bd2f19ef5 100644 --- a/models/migrations/v194.go +++ b/models/migrations/v194.go @@ -16,7 +16,7 @@ func addBranchProtectionUnprotectedFilesColumn(x *xorm.Engine) error { } if err := x.Sync2(new(ProtectedBranch)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v195.go b/models/migrations/v195.go index 06694eb57d..8594dddf1f 100644 --- a/models/migrations/v195.go +++ b/models/migrations/v195.go @@ -20,7 +20,7 @@ func addTableCommitStatusIndex(x *xorm.Engine) error { } if err := x.Sync2(new(CommitStatusIndex)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } sess := x.NewSession() diff --git a/models/migrations/v196.go b/models/migrations/v196.go index c0332c7bb4..0423d0268b 100644 --- a/models/migrations/v196.go +++ b/models/migrations/v196.go @@ -16,7 +16,7 @@ func addColorColToProjectBoard(x *xorm.Engine) error { } if err := x.Sync2(new(ProjectBoard)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v198.go b/models/migrations/v198.go index e3c31460a9..4b1515109e 100644 --- a/models/migrations/v198.go +++ b/models/migrations/v198.go @@ -27,7 +27,7 @@ func addTableIssueContentHistory(x *xorm.Engine) error { sess := x.NewSession() defer sess.Close() if err := sess.Sync2(new(IssueContentHistory)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return sess.Commit() } diff --git a/models/migrations/v200.go b/models/migrations/v200.go index 56ac06cb13..f0f107bf77 100644 --- a/models/migrations/v200.go +++ b/models/migrations/v200.go @@ -17,7 +17,7 @@ func addTableAppState(x *xorm.Engine) error { Content string `xorm:"LONGTEXT"` } if err := x.Sync2(new(AppState)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v202.go b/models/migrations/v202.go index 664728969a..1bfc28d637 100644 --- a/models/migrations/v202.go +++ b/models/migrations/v202.go @@ -18,7 +18,7 @@ func createUserSettingsTable(x *xorm.Engine) error { SettingValue string `xorm:"text"` } if err := x.Sync2(new(UserSetting)); err != nil { - return fmt.Errorf("sync2: %v", err) + return fmt.Errorf("sync2: %w", err) } return nil } diff --git a/models/migrations/v206.go b/models/migrations/v206.go index c6a5dc811c..525a475722 100644 --- a/models/migrations/v206.go +++ b/models/migrations/v206.go @@ -20,7 +20,7 @@ func addAuthorizeColForTeamUnit(x *xorm.Engine) error { } if err := x.Sync2(new(TeamUnit)); err != nil { - return fmt.Errorf("sync2: %v", err) + return fmt.Errorf("sync2: %w", err) } // migrate old permission diff --git a/models/migrations/v210.go b/models/migrations/v210.go index f32fae77ba..891c96fb30 100644 --- a/models/migrations/v210.go +++ b/models/migrations/v210.go @@ -144,7 +144,7 @@ func remigrateU2FCredentials(x *xorm.Engine) error { if !has { has, err := sess.Where("`lower_name`=?", remigrated.LowerName).And("`user_id`=?", remigrated.UserID).Exist(new(webauthnCredential)) if err != nil { - return fmt.Errorf("unable to check webauthn_credential[lower_name: %s, user_id:%v]. Error: %w", remigrated.LowerName, remigrated.UserID, err) + return fmt.Errorf("unable to check webauthn_credential[lower_name: %s, user_id: %d]. Error: %w", remigrated.LowerName, remigrated.UserID, err) } if !has { _, err = sess.Insert(remigrated) diff --git a/models/migrations/v211.go b/models/migrations/v211.go index 26ccfd2037..ec7cb46d47 100644 --- a/models/migrations/v211.go +++ b/models/migrations/v211.go @@ -20,7 +20,7 @@ func createForeignReferenceTable(x *xorm.Engine) error { } if err := x.Sync2(new(ForeignReference)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v223.go b/models/migrations/v223.go index d7ee4812b8..9f4c6acfe3 100644 --- a/models/migrations/v223.go +++ b/models/migrations/v223.go @@ -54,7 +54,7 @@ func renameCredentialIDBytes(x *xorm.Engine) error { } if err := sess.Sync2(new(webauthnCredential)); err != nil { - return fmt.Errorf("error on Sync2: %v", err) + return fmt.Errorf("error on Sync2: %w", err) } if credentialIDExist { diff --git a/models/migrations/v227.go b/models/migrations/v227.go index 8a3a9c877e..36c0a5eef1 100644 --- a/models/migrations/v227.go +++ b/models/migrations/v227.go @@ -45,7 +45,7 @@ func insertSettingsIfNotExist(x *xorm.Engine, sysSettings []*SystemSetting) erro func createSystemSettingsTable(x *xorm.Engine) error { if err := x.Sync2(new(SystemSetting)); err != nil { - return fmt.Errorf("sync2: %v", err) + return fmt.Errorf("sync2: %w", err) } // migrate xx to database diff --git a/models/migrations/v70.go b/models/migrations/v70.go index 7d34c89d11..b2563544b2 100644 --- a/models/migrations/v70.go +++ b/models/migrations/v70.go @@ -38,7 +38,7 @@ func addIssueDependencies(x *xorm.Engine) (err error) { ) if err = x.Sync(new(IssueDependency)); err != nil { - return fmt.Errorf("Error creating issue_dependency_table column definition: %v", err) + return fmt.Errorf("Error creating issue_dependency_table column definition: %w", err) } // Update Comment definition @@ -76,7 +76,7 @@ func addIssueDependencies(x *xorm.Engine) (err error) { } if err = x.Sync(new(Comment)); err != nil { - return fmt.Errorf("Error updating issue_comment table column definition: %v", err) + return fmt.Errorf("Error updating issue_comment table column definition: %w", err) } // RepoUnit describes all units of a repository @@ -93,7 +93,7 @@ func addIssueDependencies(x *xorm.Engine) (err error) { units := make([]*RepoUnit, 0, 100) err = x.Where("`type` = ?", v16UnitTypeIssues).Find(&units) if err != nil { - return fmt.Errorf("Query repo units: %v", err) + return fmt.Errorf("Query repo units: %w", err) } for _, unit := range units { if unit.Config == nil { diff --git a/models/migrations/v71.go b/models/migrations/v71.go index 163ec3ee5f..70314386d7 100644 --- a/models/migrations/v71.go +++ b/models/migrations/v71.go @@ -30,7 +30,7 @@ func addScratchHash(x *xorm.Engine) error { } if err := x.Sync2(new(TwoFactor)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } sess := x.NewSession() @@ -61,7 +61,7 @@ func addScratchHash(x *xorm.Engine) error { tfa.ScratchHash = hashToken(tfa.ScratchToken, salt) if _, err := sess.ID(tfa.ID).Cols("scratch_salt, scratch_hash").Update(tfa); err != nil { - return fmt.Errorf("couldn't add in scratch_hash and scratch_salt: %v", err) + return fmt.Errorf("couldn't add in scratch_hash and scratch_salt: %w", err) } } diff --git a/models/migrations/v72.go b/models/migrations/v72.go index 612f58aab5..2be4233863 100644 --- a/models/migrations/v72.go +++ b/models/migrations/v72.go @@ -25,7 +25,7 @@ func addReview(x *xorm.Engine) error { } if err := x.Sync2(new(Review)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return nil } diff --git a/models/migrations/v76.go b/models/migrations/v76.go index a82ae40ba7..2686422723 100644 --- a/models/migrations/v76.go +++ b/models/migrations/v76.go @@ -43,7 +43,7 @@ func addPullRequestRebaseWithMerge(x *xorm.Engine) error { // Updating existing issue units units := make([]*RepoUnit, 0, 100) if err := sess.Where("`type` = ?", v16UnitTypePRs).Find(&units); err != nil { - return fmt.Errorf("Query repo units: %v", err) + return fmt.Errorf("Query repo units: %w", err) } for _, unit := range units { if unit.Config == nil { diff --git a/models/migrations/v81.go b/models/migrations/v81.go index 4e9e7658ee..5141f97576 100644 --- a/models/migrations/v81.go +++ b/models/migrations/v81.go @@ -24,7 +24,7 @@ func changeU2FCounterType(x *xorm.Engine) error { } if err != nil { - return fmt.Errorf("Error changing u2f_registration counter column type: %v", err) + return fmt.Errorf("Error changing u2f_registration counter column type: %w", err) } return nil diff --git a/models/migrations/v85.go b/models/migrations/v85.go index 9611d6e72a..317660eb6f 100644 --- a/models/migrations/v85.go +++ b/models/migrations/v85.go @@ -41,7 +41,7 @@ func hashAppToken(x *xorm.Engine) error { } if err := sess.Sync2(new(AccessToken)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } if err := sess.Commit(); err != nil { @@ -79,7 +79,7 @@ func hashAppToken(x *xorm.Engine) error { token.Sha1 = "" // ensure to blank out column in case drop column doesn't work if _, err := sess.ID(token.ID).Cols("token_hash, token_salt, token_last_eight, sha1").Update(token); err != nil { - return fmt.Errorf("couldn't add in sha1, token_hash, token_salt and token_last_eight: %v", err) + return fmt.Errorf("couldn't add in sha1, token_hash, token_salt and token_last_eight: %w", err) } } @@ -113,7 +113,7 @@ func resyncHashAppTokenWithUniqueHash(x *xorm.Engine) error { return err } if err := sess.Sync2(new(AccessToken)); err != nil { - return fmt.Errorf("Sync2: %v", err) + return fmt.Errorf("Sync2: %w", err) } return sess.Commit() } |