Replace interface{} with any (#25686) (#25687)

Same perl replacement as https://github.com/go-gitea/gitea/pull/25686
but for 1.20 to ease future backporting.
This commit is contained in:
silverwind 2023-07-05 05:41:32 +02:00 committed by GitHub
parent 4e310133f9
commit 24e64fe372
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
233 changed files with 729 additions and 729 deletions

View file

@ -27,7 +27,7 @@ import (
// RecreateTables will recreate the tables for the provided beans using the newly provided bean definition and move all data to that new table
// WARNING: YOU MUST PROVIDE THE FULL BEAN DEFINITION
func RecreateTables(beans ...interface{}) func(*xorm.Engine) error {
func RecreateTables(beans ...any) func(*xorm.Engine) error {
return func(x *xorm.Engine) error {
sess := x.NewSession()
defer sess.Close()
@ -48,7 +48,7 @@ func RecreateTables(beans ...interface{}) func(*xorm.Engine) error {
// RecreateTable will recreate the table using the newly provided bean definition and move all data to that new table
// WARNING: YOU MUST PROVIDE THE FULL BEAN DEFINITION
// WARNING: YOU MUST COMMIT THE SESSION AT THE END
func RecreateTable(sess *xorm.Session, bean interface{}) error {
func RecreateTable(sess *xorm.Session, bean any) error {
// TODO: This will not work if there are foreign keys
tableName := sess.Engine().TableName(bean)

View file

@ -30,7 +30,7 @@ import (
// Provide models to be sync'd with the database - in particular any models you expect fixtures to be loaded from.
//
// fixtures in `models/migrations/fixtures/<TestName>` will be loaded automatically
func PrepareTestEnv(t *testing.T, skip int, syncModels ...interface{}) (*xorm.Engine, func()) {
func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, func()) {
t.Helper()
ourSkip := 2
ourSkip += skip

View file

@ -59,11 +59,11 @@ func UpdateMigrationServiceTypes(x *xorm.Engine) error {
}
type ExternalLoginUser struct {
ExternalID string `xorm:"pk NOT NULL"`
UserID int64 `xorm:"INDEX NOT NULL"`
LoginSourceID int64 `xorm:"pk NOT NULL"`
RawData map[string]interface{} `xorm:"TEXT JSON"`
Provider string `xorm:"index VARCHAR(25)"`
ExternalID string `xorm:"pk NOT NULL"`
UserID int64 `xorm:"INDEX NOT NULL"`
LoginSourceID int64 `xorm:"pk NOT NULL"`
RawData map[string]any `xorm:"TEXT JSON"`
Provider string `xorm:"index VARCHAR(25)"`
Email string
Name string
FirstName string

View file

@ -14,7 +14,7 @@ import (
)
func UnwrapLDAPSourceCfg(x *xorm.Engine) error {
jsonUnmarshalHandleDoubleEncode := func(bs []byte, v interface{}) error {
jsonUnmarshalHandleDoubleEncode := func(bs []byte, v any) error {
err := json.Unmarshal(bs, v)
if err != nil {
ok := true
@ -54,7 +54,7 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error {
const dldapType = 5
type WrappedSource struct {
Source map[string]interface{}
Source map[string]any
}
// change lower_email as unique
@ -77,7 +77,7 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error {
for _, source := range sources {
wrapped := &WrappedSource{
Source: map[string]interface{}{},
Source: map[string]any{},
}
err := jsonUnmarshalHandleDoubleEncode([]byte(source.Cfg), &wrapped)
if err != nil {

View file

@ -62,8 +62,8 @@ func Test_UnwrapLDAPSourceCfg(t *testing.T) {
}
for _, source := range sources {
converted := map[string]interface{}{}
expected := map[string]interface{}{}
converted := map[string]any{}
expected := map[string]any{}
if err := json.Unmarshal([]byte(source.Cfg), &converted); err != nil {
assert.NoError(t, err)

View file

@ -79,7 +79,7 @@ func Test_AddHeaderAuthorizationEncryptedColWebhook(t *testing.T) {
return
}
for _, h := range hookTasks {
var m map[string]interface{}
var m map[string]any
err := json.Unmarshal([]byte(h.PayloadContent), &m)
assert.NoError(t, err)
assert.Nil(t, m["access_token"])

View file

@ -81,11 +81,11 @@ func AddIssueDependencies(x *xorm.Engine) (err error) {
// RepoUnit describes all units of a repository
type RepoUnit struct {
ID int64
RepoID int64 `xorm:"INDEX(s)"`
Type int `xorm:"INDEX(s)"`
Config map[string]interface{} `xorm:"JSON"`
CreatedUnix int64 `xorm:"INDEX CREATED"`
Created time.Time `xorm:"-"`
RepoID int64 `xorm:"INDEX(s)"`
Type int `xorm:"INDEX(s)"`
Config map[string]any `xorm:"JSON"`
CreatedUnix int64 `xorm:"INDEX CREATED"`
Created time.Time `xorm:"-"`
}
// Updating existing issue units
@ -96,7 +96,7 @@ func AddIssueDependencies(x *xorm.Engine) (err error) {
}
for _, unit := range units {
if unit.Config == nil {
unit.Config = make(map[string]interface{})
unit.Config = make(map[string]any)
}
if _, ok := unit.Config["EnableDependencies"]; !ok {
unit.Config["EnableDependencies"] = setting.Service.DefaultEnableDependencies

View file

@ -15,10 +15,10 @@ func AddPullRequestRebaseWithMerge(x *xorm.Engine) error {
// RepoUnit describes all units of a repository
type RepoUnit struct {
ID int64
RepoID int64 `xorm:"INDEX(s)"`
Type int `xorm:"INDEX(s)"`
Config map[string]interface{} `xorm:"JSON"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX CREATED"`
RepoID int64 `xorm:"INDEX(s)"`
Type int `xorm:"INDEX(s)"`
Config map[string]any `xorm:"JSON"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX CREATED"`
}
const (
@ -46,7 +46,7 @@ func AddPullRequestRebaseWithMerge(x *xorm.Engine) error {
}
for _, unit := range units {
if unit.Config == nil {
unit.Config = make(map[string]interface{})
unit.Config = make(map[string]any)
}
// Allow the new merge style if all other merge styles are allowed
allowMergeRebase := true