mirror of
https://github.com/gogs/gogs.git
synced 2025-05-21 23:10:27 +00:00
all: replace interface{}
with any
(#7330)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
parent
614382fec0
commit
c53a1998c5
@ -84,7 +84,7 @@ type Provider interface {
|
|||||||
Authenticate(login, password string) (*ExternalAccount, error)
|
Authenticate(login, password string) (*ExternalAccount, error)
|
||||||
|
|
||||||
// Config returns the underlying configuration of the authenticate provider.
|
// Config returns the underlying configuration of the authenticate provider.
|
||||||
Config() interface{}
|
Config() any
|
||||||
// HasTLS returns true if the authenticate provider supports TLS.
|
// HasTLS returns true if the authenticate provider supports TLS.
|
||||||
HasTLS() bool
|
HasTLS() bool
|
||||||
// UseTLS returns true if the authenticate provider is configured to use TLS.
|
// UseTLS returns true if the authenticate provider is configured to use TLS.
|
||||||
|
@ -26,7 +26,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
fullname, email, website, location, err := p.config.doAuth(login, password)
|
fullname, email, website, location, err := p.config.doAuth(login, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "401") {
|
if strings.Contains(err.Error(), "401") {
|
||||||
return nil, auth.ErrBadCredentials{Args: map[string]interface{}{"login": login}}
|
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login}}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) Config() interface{} {
|
func (p *Provider) Config() any {
|
||||||
return p.config
|
return p.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ func NewProvider(directBind bool, cfg *Config) auth.Provider {
|
|||||||
func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount, error) {
|
func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount, error) {
|
||||||
username, fn, sn, email, isAdmin, succeed := p.config.searchEntry(login, password, p.directBind)
|
username, fn, sn, email, isAdmin, succeed := p.config.searchEntry(login, password, p.directBind)
|
||||||
if !succeed {
|
if !succeed {
|
||||||
return nil, auth.ErrBadCredentials{Args: map[string]interface{}{"login": login}}
|
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login}}
|
||||||
}
|
}
|
||||||
|
|
||||||
if username == "" {
|
if username == "" {
|
||||||
@ -61,7 +61,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) Config() interface{} {
|
func (p *Provider) Config() any {
|
||||||
return p.config
|
return p.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
err := p.config.doAuth(login, password)
|
err := p.config.doAuth(login, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "Authentication failure") {
|
if strings.Contains(err.Error(), "Authentication failure") {
|
||||||
return nil, auth.ErrBadCredentials{Args: map[string]interface{}{"login": login}}
|
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login}}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) Config() interface{} {
|
func (p *Provider) Config() any {
|
||||||
return p.config
|
return p.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
if p.config.AllowedDomains != "" {
|
if p.config.AllowedDomains != "" {
|
||||||
fields := strings.SplitN(login, "@", 3)
|
fields := strings.SplitN(login, "@", 3)
|
||||||
if len(fields) != 2 {
|
if len(fields) != 2 {
|
||||||
return nil, auth.ErrBadCredentials{Args: map[string]interface{}{"login": login}}
|
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login}}
|
||||||
}
|
}
|
||||||
domain := fields[1]
|
domain := fields[1]
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !isAllowed {
|
if !isAllowed {
|
||||||
return nil, auth.ErrBadCredentials{Args: map[string]interface{}{"login": login}}
|
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
tperr, ok := err.(*textproto.Error)
|
tperr, ok := err.(*textproto.Error)
|
||||||
if (ok && tperr.Code == 535) ||
|
if (ok && tperr.Code == 535) ||
|
||||||
strings.Contains(err.Error(), "Username and Password not accepted") {
|
strings.Contains(err.Error(), "Username and Password not accepted") {
|
||||||
return nil, auth.ErrBadCredentials{Args: map[string]interface{}{"login": login}}
|
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login}}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) Config() interface{} {
|
func (p *Provider) Config() any {
|
||||||
return p.config
|
return p.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files.`,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func publicKey(priv interface{}) interface{} {
|
func publicKey(priv any) any {
|
||||||
switch k := priv.(type) {
|
switch k := priv.(type) {
|
||||||
case *rsa.PrivateKey:
|
case *rsa.PrivateKey:
|
||||||
return &k.PublicKey
|
return &k.PublicKey
|
||||||
@ -52,7 +52,7 @@ func publicKey(priv interface{}) interface{} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func pemBlockForKey(priv interface{}) *pem.Block {
|
func pemBlockForKey(priv any) *pem.Block {
|
||||||
switch k := priv.(type) {
|
switch k := priv.(type) {
|
||||||
case *rsa.PrivateKey:
|
case *rsa.PrivateKey:
|
||||||
return &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(k)}
|
return &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(k)}
|
||||||
@ -72,7 +72,7 @@ func runCert(ctx *cli.Context) error {
|
|||||||
log.Fatal("Missing required --host parameter")
|
log.Fatal("Missing required --host parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
var priv interface{}
|
var priv any
|
||||||
var err error
|
var err error
|
||||||
switch ctx.String("ecdsa-curve") {
|
switch ctx.String("ecdsa-curve") {
|
||||||
case "":
|
case "":
|
||||||
|
@ -38,7 +38,7 @@ var Serv = cli.Command{
|
|||||||
// fail prints user message to the Git client (i.e. os.Stderr) and
|
// fail prints user message to the Git client (i.e. os.Stderr) and
|
||||||
// logs error message on the server side. When not in "prod" mode,
|
// logs error message on the server side. When not in "prod" mode,
|
||||||
// error message is also printed to the client for easier debugging.
|
// error message is also printed to the client for easier debugging.
|
||||||
func fail(userMessage, errMessage string, args ...interface{}) {
|
func fail(userMessage, errMessage string, args ...any) {
|
||||||
_, _ = fmt.Fprintln(os.Stderr, "Gogs:", userMessage)
|
_, _ = fmt.Fprintln(os.Stderr, "Gogs:", userMessage)
|
||||||
|
|
||||||
if len(errMessage) > 0 {
|
if len(errMessage) > 0 {
|
||||||
|
@ -29,7 +29,7 @@ func TestInit(t *testing.T) {
|
|||||||
|
|
||||||
for _, v := range []struct {
|
for _, v := range []struct {
|
||||||
section string
|
section string
|
||||||
config interface{}
|
config any
|
||||||
}{
|
}{
|
||||||
{"", &App},
|
{"", &App},
|
||||||
{"server", &Server},
|
{"server", &Server},
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
type loggerConf struct {
|
type loggerConf struct {
|
||||||
Buffer int64
|
Buffer int64
|
||||||
Config interface{}
|
Config any
|
||||||
}
|
}
|
||||||
|
|
||||||
type logConf struct {
|
type logConf struct {
|
||||||
|
@ -58,7 +58,7 @@ func (c *APIContext) Error(err error, msg string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Errorf renders the 500 response with formatted message.
|
// Errorf renders the 500 response with formatted message.
|
||||||
func (c *APIContext) Errorf(err error, format string, args ...interface{}) {
|
func (c *APIContext) Errorf(err error, format string, args ...any) {
|
||||||
c.Error(err, fmt.Sprintf(format, args...))
|
c.Error(err, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ func (c *Context) Success(name string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// JSONSuccess responses JSON with status http.StatusOK.
|
// JSONSuccess responses JSON with status http.StatusOK.
|
||||||
func (c *Context) JSONSuccess(data interface{}) {
|
func (c *Context) JSONSuccess(data any) {
|
||||||
c.JSON(http.StatusOK, data)
|
c.JSON(http.StatusOK, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ func (c *Context) RedirectSubpath(location string, status ...int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RenderWithErr used for page has form validation but need to prompt error to users.
|
// RenderWithErr used for page has form validation but need to prompt error to users.
|
||||||
func (c *Context) RenderWithErr(msg, tpl string, f interface{}) {
|
func (c *Context) RenderWithErr(msg, tpl string, f any) {
|
||||||
if f != nil {
|
if f != nil {
|
||||||
form.Assign(f, c.Data)
|
form.Assign(f, c.Data)
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ func (c *Context) Error(err error, msg string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Errorf renders the 500 response with formatted message.
|
// Errorf renders the 500 response with formatted message.
|
||||||
func (c *Context) Errorf(err error, format string, args ...interface{}) {
|
func (c *Context) Errorf(err error, format string, args ...any) {
|
||||||
c.Error(err, fmt.Sprintf(format, args...))
|
c.Error(err, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ func (c *Context) NotFoundOrError(err error, msg string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NotFoundOrErrorf is same as NotFoundOrError but with formatted message.
|
// NotFoundOrErrorf is same as NotFoundOrError but with formatted message.
|
||||||
func (c *Context) NotFoundOrErrorf(err error, format string, args ...interface{}) {
|
func (c *Context) NotFoundOrErrorf(err error, format string, args ...any) {
|
||||||
c.NotFoundOrError(err, fmt.Sprintf(format, args...))
|
c.NotFoundOrError(err, fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ func (c *Context) PlainText(status int, msg string) {
|
|||||||
c.Render.PlainText(status, []byte(msg))
|
c.Render.PlainText(status, []byte(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) {
|
func (c *Context) ServeContent(name string, r io.ReadSeeker, params ...any) {
|
||||||
modtime := time.Now()
|
modtime := time.Now()
|
||||||
for _, p := range params {
|
for _, p := range params {
|
||||||
switch v := p.(type) {
|
switch v := p.(type) {
|
||||||
|
@ -96,7 +96,7 @@ func (r *Repository) Editorconfig() (*editorconfig.Editorconfig, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MakeURL accepts a string or url.URL as argument and returns escaped URL prepended with repository URL.
|
// MakeURL accepts a string or url.URL as argument and returns escaped URL prepended with repository URL.
|
||||||
func (r *Repository) MakeURL(location interface{}) string {
|
func (r *Repository) MakeURL(location any) string {
|
||||||
switch location := location.(type) {
|
switch location := location.(type) {
|
||||||
case string:
|
case string:
|
||||||
tempURL := url.URL{
|
tempURL := url.URL{
|
||||||
|
@ -98,7 +98,7 @@ func TestAccessTokens(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(AccessToken)}
|
tables := []any{new(AccessToken)}
|
||||||
db := &accessTokens{
|
db := &accessTokens{
|
||||||
DB: dbtest.NewDB(t, "accessTokens", tables...),
|
DB: dbtest.NewDB(t, "accessTokens", tables...),
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ func TestActions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(Action), new(User), new(Repository), new(EmailAddress), new(Watch)}
|
tables := []any{new(Action), new(User), new(Repository), new(EmailAddress), new(Watch)}
|
||||||
db := &actions{
|
db := &actions{
|
||||||
DB: dbtest.NewDB(t, "actions", tables...),
|
DB: dbtest.NewDB(t, "actions", tables...),
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func NewAttachment(name string, buf []byte, file multipart.File) (_ *Attachment,
|
|||||||
var _ errutil.NotFound = (*ErrAttachmentNotExist)(nil)
|
var _ errutil.NotFound = (*ErrAttachmentNotExist)(nil)
|
||||||
|
|
||||||
type ErrAttachmentNotExist struct {
|
type ErrAttachmentNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrAttachmentNotExist(err error) bool {
|
func IsErrAttachmentNotExist(err error) bool {
|
||||||
@ -109,7 +109,7 @@ func getAttachmentByUUID(e Engine, uuid string) (*Attachment, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrAttachmentNotExist{args: map[string]interface{}{"uuid": uuid}}
|
return nil, ErrAttachmentNotExist{args: map[string]any{"uuid": uuid}}
|
||||||
}
|
}
|
||||||
return attach, nil
|
return attach, nil
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
// getTableType returns the type name of a table definition without package name,
|
// getTableType returns the type name of a table definition without package name,
|
||||||
// e.g. *db.LFSObject -> LFSObject.
|
// e.g. *db.LFSObject -> LFSObject.
|
||||||
func getTableType(t interface{}) string {
|
func getTableType(t any) string {
|
||||||
return strings.TrimPrefix(fmt.Sprintf("%T", t), "*db.")
|
return strings.TrimPrefix(fmt.Sprintf("%T", t), "*db.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ func DumpDatabase(ctx context.Context, db *gorm.DB, dirPath string, verbose bool
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpTable(ctx context.Context, db *gorm.DB, table interface{}, w io.Writer) error {
|
func dumpTable(ctx context.Context, db *gorm.DB, table any, w io.Writer) error {
|
||||||
query := db.WithContext(ctx).Model(table)
|
query := db.WithContext(ctx).Model(table)
|
||||||
switch table.(type) {
|
switch table.(type) {
|
||||||
case *LFSObject:
|
case *LFSObject:
|
||||||
@ -128,7 +128,7 @@ func dumpLegacyTables(ctx context.Context, dirPath string, verbose bool) error {
|
|||||||
return fmt.Errorf("create JSON file: %v", err)
|
return fmt.Errorf("create JSON file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = x.Context(ctx).Asc("id").Iterate(table, func(idx int, bean interface{}) (err error) {
|
if err = x.Context(ctx).Asc("id").Iterate(table, func(idx int, bean any) (err error) {
|
||||||
return jsoniter.NewEncoder(f).Encode(bean)
|
return jsoniter.NewEncoder(f).Encode(bean)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
_ = f.Close()
|
_ = f.Close()
|
||||||
@ -181,7 +181,7 @@ func ImportDatabase(ctx context.Context, db *gorm.DB, dirPath string, verbose bo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func importTable(ctx context.Context, db *gorm.DB, table interface{}, r io.Reader) error {
|
func importTable(ctx context.Context, db *gorm.DB, table any, r io.Reader) error {
|
||||||
err := db.WithContext(ctx).Migrator().DropTable(table)
|
err := db.WithContext(ctx).Migrator().DropTable(table)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "drop table")
|
return errors.Wrap(err, "drop table")
|
||||||
|
@ -45,7 +45,7 @@ func TestDumpAndImport(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupDBToDump(t *testing.T, db *gorm.DB) {
|
func setupDBToDump(t *testing.T, db *gorm.DB) {
|
||||||
vals := []interface{}{
|
vals := []any{
|
||||||
&Access{
|
&Access{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
UserID: 1,
|
UserID: 1,
|
||||||
|
@ -395,7 +395,7 @@ func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commi
|
|||||||
var _ errutil.NotFound = (*ErrCommentNotExist)(nil)
|
var _ errutil.NotFound = (*ErrCommentNotExist)(nil)
|
||||||
|
|
||||||
type ErrCommentNotExist struct {
|
type ErrCommentNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrCommentNotExist(err error) bool {
|
func IsErrCommentNotExist(err error) bool {
|
||||||
@ -418,7 +418,7 @@ func GetCommentByID(id int64) (*Comment, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrCommentNotExist{args: map[string]interface{}{"commentID": id}}
|
return nil, ErrCommentNotExist{args: map[string]any{"commentID": id}}
|
||||||
}
|
}
|
||||||
return c, c.LoadAttributes()
|
return c, c.LoadAttributes()
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ func newLogWriter() (logger.Writer, error) {
|
|||||||
// Tables is the list of struct-to-table mappings.
|
// Tables is the list of struct-to-table mappings.
|
||||||
//
|
//
|
||||||
// NOTE: Lines are sorted in alphabetical order, each letter in its own line.
|
// NOTE: Lines are sorted in alphabetical order, each letter in its own line.
|
||||||
var Tables = []interface{}{
|
var Tables = []any{
|
||||||
new(Access), new(AccessToken), new(Action),
|
new(Access), new(AccessToken), new(Action),
|
||||||
new(Follow),
|
new(Follow),
|
||||||
new(LFSObject), new(LoginSource),
|
new(LFSObject), new(LoginSource),
|
||||||
|
@ -21,7 +21,7 @@ func TestEmailAddresses(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(EmailAddress)}
|
tables := []any{new(EmailAddress)}
|
||||||
db := &emailAddresses{
|
db := &emailAddresses{
|
||||||
DB: dbtest.NewDB(t, "emailAddresses", tables...),
|
DB: dbtest.NewDB(t, "emailAddresses", tables...),
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ func TestFollows(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(User), new(EmailAddress), new(Follow)}
|
tables := []any{new(User), new(EmailAddress), new(Follow)}
|
||||||
db := &follows{
|
db := &follows{
|
||||||
DB: dbtest.NewDB(t, "follows", tables...),
|
DB: dbtest.NewDB(t, "follows", tables...),
|
||||||
}
|
}
|
||||||
|
@ -793,7 +793,7 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
|
|||||||
var _ errutil.NotFound = (*ErrIssueNotExist)(nil)
|
var _ errutil.NotFound = (*ErrIssueNotExist)(nil)
|
||||||
|
|
||||||
type ErrIssueNotExist struct {
|
type ErrIssueNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrIssueNotExist(err error) bool {
|
func IsErrIssueNotExist(err error) bool {
|
||||||
@ -813,12 +813,12 @@ func (ErrIssueNotExist) NotFound() bool {
|
|||||||
func GetIssueByRef(ref string) (*Issue, error) {
|
func GetIssueByRef(ref string) (*Issue, error) {
|
||||||
n := strings.IndexByte(ref, byte('#'))
|
n := strings.IndexByte(ref, byte('#'))
|
||||||
if n == -1 {
|
if n == -1 {
|
||||||
return nil, ErrIssueNotExist{args: map[string]interface{}{"ref": ref}}
|
return nil, ErrIssueNotExist{args: map[string]any{"ref": ref}}
|
||||||
}
|
}
|
||||||
|
|
||||||
index := com.StrTo(ref[n+1:]).MustInt64()
|
index := com.StrTo(ref[n+1:]).MustInt64()
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
return nil, ErrIssueNotExist{args: map[string]interface{}{"ref": ref}}
|
return nil, ErrIssueNotExist{args: map[string]any{"ref": ref}}
|
||||||
}
|
}
|
||||||
|
|
||||||
repo, err := GetRepositoryByRef(ref[:n])
|
repo, err := GetRepositoryByRef(ref[:n])
|
||||||
@ -844,7 +844,7 @@ func GetRawIssueByIndex(repoID, index int64) (*Issue, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrIssueNotExist{args: map[string]interface{}{"repoID": repoID, "index": index}}
|
return nil, ErrIssueNotExist{args: map[string]any{"repoID": repoID, "index": index}}
|
||||||
}
|
}
|
||||||
return issue, nil
|
return issue, nil
|
||||||
}
|
}
|
||||||
@ -864,7 +864,7 @@ func getRawIssueByID(e Engine, id int64) (*Issue, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrIssueNotExist{args: map[string]interface{}{"issueID": id}}
|
return nil, ErrIssueNotExist{args: map[string]any{"issueID": id}}
|
||||||
}
|
}
|
||||||
return issue, nil
|
return issue, nil
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ func NewLabels(labels ...*Label) error {
|
|||||||
var _ errutil.NotFound = (*ErrLabelNotExist)(nil)
|
var _ errutil.NotFound = (*ErrLabelNotExist)(nil)
|
||||||
|
|
||||||
type ErrLabelNotExist struct {
|
type ErrLabelNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrLabelNotExist(err error) bool {
|
func IsErrLabelNotExist(err error) bool {
|
||||||
@ -128,7 +128,7 @@ func (ErrLabelNotExist) NotFound() bool {
|
|||||||
// and can return arbitrary label with any valid ID.
|
// and can return arbitrary label with any valid ID.
|
||||||
func getLabelOfRepoByName(e Engine, repoID int64, labelName string) (*Label, error) {
|
func getLabelOfRepoByName(e Engine, repoID int64, labelName string) (*Label, error) {
|
||||||
if len(labelName) <= 0 {
|
if len(labelName) <= 0 {
|
||||||
return nil, ErrLabelNotExist{args: map[string]interface{}{"repoID": repoID}}
|
return nil, ErrLabelNotExist{args: map[string]any{"repoID": repoID}}
|
||||||
}
|
}
|
||||||
|
|
||||||
l := &Label{
|
l := &Label{
|
||||||
@ -139,7 +139,7 @@ func getLabelOfRepoByName(e Engine, repoID int64, labelName string) (*Label, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrLabelNotExist{args: map[string]interface{}{"repoID": repoID}}
|
return nil, ErrLabelNotExist{args: map[string]any{"repoID": repoID}}
|
||||||
}
|
}
|
||||||
return l, nil
|
return l, nil
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ func getLabelOfRepoByName(e Engine, repoID int64, labelName string) (*Label, err
|
|||||||
// and can return arbitrary label with any valid ID.
|
// and can return arbitrary label with any valid ID.
|
||||||
func getLabelOfRepoByID(e Engine, repoID, labelID int64) (*Label, error) {
|
func getLabelOfRepoByID(e Engine, repoID, labelID int64) (*Label, error) {
|
||||||
if labelID <= 0 {
|
if labelID <= 0 {
|
||||||
return nil, ErrLabelNotExist{args: map[string]interface{}{"repoID": repoID, "labelID": labelID}}
|
return nil, ErrLabelNotExist{args: map[string]any{"repoID": repoID, "labelID": labelID}}
|
||||||
}
|
}
|
||||||
|
|
||||||
l := &Label{
|
l := &Label{
|
||||||
@ -160,7 +160,7 @@ func getLabelOfRepoByID(e Engine, repoID, labelID int64) (*Label, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrLabelNotExist{args: map[string]interface{}{"repoID": repoID, "labelID": labelID}}
|
return nil, ErrLabelNotExist{args: map[string]any{"repoID": repoID, "labelID": labelID}}
|
||||||
}
|
}
|
||||||
return l, nil
|
return l, nil
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ func TestLFS(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(LFSObject)}
|
tables := []any{new(LFSObject)}
|
||||||
db := &lfs{
|
db := &lfs{
|
||||||
DB: dbtest.NewDB(t, "lfs", tables...),
|
DB: dbtest.NewDB(t, "lfs", tables...),
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ type loginSourceFileStore interface {
|
|||||||
// SetGeneral sets new value to the given key in the general (default) section.
|
// SetGeneral sets new value to the given key in the general (default) section.
|
||||||
SetGeneral(name, value string)
|
SetGeneral(name, value string)
|
||||||
// SetConfig sets new values to the "config" section.
|
// SetConfig sets new values to the "config" section.
|
||||||
SetConfig(cfg interface{}) error
|
SetConfig(cfg any) error
|
||||||
// Save persists values to file system.
|
// Save persists values to file system.
|
||||||
Save() error
|
Save() error
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ func (f *loginSourceFile) SetGeneral(name, value string) {
|
|||||||
f.file.Section("").Key(name).SetValue(value)
|
f.file.Section("").Key(name).SetValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *loginSourceFile) SetConfig(cfg interface{}) error {
|
func (f *loginSourceFile) SetConfig(cfg any) error {
|
||||||
return f.file.Section("config").ReflectFrom(cfg)
|
return f.file.Section("config").ReflectFrom(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ type CreateLoginSourceOptions struct {
|
|||||||
Name string
|
Name string
|
||||||
Activated bool
|
Activated bool
|
||||||
Default bool
|
Default bool
|
||||||
Config interface{}
|
Config any
|
||||||
}
|
}
|
||||||
|
|
||||||
type ErrLoginSourceAlreadyExist struct {
|
type ErrLoginSourceAlreadyExist struct {
|
||||||
@ -297,7 +297,7 @@ func (db *loginSources) ResetNonDefault(ctx context.Context, dflt *LoginSource)
|
|||||||
err := db.WithContext(ctx).
|
err := db.WithContext(ctx).
|
||||||
Model(new(LoginSource)).
|
Model(new(LoginSource)).
|
||||||
Where("id != ?", dflt.ID).
|
Where("id != ?", dflt.ID).
|
||||||
Updates(map[string]interface{}{"is_default": false}).
|
Updates(map[string]any{"is_default": false}).
|
||||||
Error
|
Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -163,7 +163,7 @@ func TestLoginSources(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(LoginSource), new(User)}
|
tables := []any{new(LoginSource), new(User)}
|
||||||
db := &loginSources{
|
db := &loginSources{
|
||||||
DB: dbtest.NewDB(t, "loginSources", tables...),
|
DB: dbtest.NewDB(t, "loginSources", tables...),
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clearTables removes all rows from given tables.
|
// clearTables removes all rows from given tables.
|
||||||
func clearTables(t *testing.T, db *gorm.DB, tables ...interface{}) error {
|
func clearTables(t *testing.T, db *gorm.DB, tables ...any) error {
|
||||||
if t.Failed() {
|
if t.Failed() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ func NewMilestone(m *Milestone) (err error) {
|
|||||||
var _ errutil.NotFound = (*ErrMilestoneNotExist)(nil)
|
var _ errutil.NotFound = (*ErrMilestoneNotExist)(nil)
|
||||||
|
|
||||||
type ErrMilestoneNotExist struct {
|
type ErrMilestoneNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrMilestoneNotExist(err error) bool {
|
func IsErrMilestoneNotExist(err error) bool {
|
||||||
@ -159,7 +159,7 @@ func getMilestoneByRepoID(e Engine, repoID, id int64) (*Milestone, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrMilestoneNotExist{args: map[string]interface{}{"repoID": repoID, "milestoneID": id}}
|
return nil, ErrMilestoneNotExist{args: map[string]any{"repoID": repoID, "milestoneID": id}}
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ func MirrorUpdate() {
|
|||||||
|
|
||||||
log.Trace("Doing: MirrorUpdate")
|
log.Trace("Doing: MirrorUpdate")
|
||||||
|
|
||||||
if err := x.Where("next_update_unix<=?", time.Now().Unix()).Iterate(new(Mirror), func(idx int, bean interface{}) error {
|
if err := x.Where("next_update_unix<=?", time.Now().Unix()).Iterate(new(Mirror), func(idx int, bean any) error {
|
||||||
m := bean.(*Mirror)
|
m := bean.(*Mirror)
|
||||||
if m.Repo == nil {
|
if m.Repo == nil {
|
||||||
log.Error("Disconnected mirror repository found: %d", m.ID)
|
log.Error("Disconnected mirror repository found: %d", m.ID)
|
||||||
|
@ -28,23 +28,23 @@ import (
|
|||||||
|
|
||||||
// Engine represents a XORM engine or session.
|
// Engine represents a XORM engine or session.
|
||||||
type Engine interface {
|
type Engine interface {
|
||||||
Delete(interface{}) (int64, error)
|
Delete(any) (int64, error)
|
||||||
Exec(...interface{}) (sql.Result, error)
|
Exec(...any) (sql.Result, error)
|
||||||
Find(interface{}, ...interface{}) error
|
Find(any, ...any) error
|
||||||
Get(interface{}) (bool, error)
|
Get(any) (bool, error)
|
||||||
ID(interface{}) *xorm.Session
|
ID(any) *xorm.Session
|
||||||
In(string, ...interface{}) *xorm.Session
|
In(string, ...any) *xorm.Session
|
||||||
Insert(...interface{}) (int64, error)
|
Insert(...any) (int64, error)
|
||||||
InsertOne(interface{}) (int64, error)
|
InsertOne(any) (int64, error)
|
||||||
Iterate(interface{}, xorm.IterFunc) error
|
Iterate(any, xorm.IterFunc) error
|
||||||
Sql(string, ...interface{}) *xorm.Session
|
Sql(string, ...any) *xorm.Session
|
||||||
Table(interface{}) *xorm.Session
|
Table(any) *xorm.Session
|
||||||
Where(interface{}, ...interface{}) *xorm.Session
|
Where(any, ...any) *xorm.Session
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
x *xorm.Engine
|
x *xorm.Engine
|
||||||
legacyTables []interface{}
|
legacyTables []any
|
||||||
HasEngine bool
|
HasEngine bool
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ func NewTeam(t *Team) error {
|
|||||||
var _ errutil.NotFound = (*ErrTeamNotExist)(nil)
|
var _ errutil.NotFound = (*ErrTeamNotExist)(nil)
|
||||||
|
|
||||||
type ErrTeamNotExist struct {
|
type ErrTeamNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrTeamNotExist(err error) bool {
|
func IsErrTeamNotExist(err error) bool {
|
||||||
@ -329,7 +329,7 @@ func getTeamOfOrgByName(e Engine, orgID int64, name string) (*Team, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrTeamNotExist{args: map[string]interface{}{"orgID": orgID, "name": name}}
|
return nil, ErrTeamNotExist{args: map[string]any{"orgID": orgID, "name": name}}
|
||||||
}
|
}
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ func getTeamByID(e Engine, teamID int64) (*Team, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrTeamNotExist{args: map[string]interface{}{"teamID": teamID}}
|
return nil, ErrTeamNotExist{args: map[string]any{"teamID": teamID}}
|
||||||
}
|
}
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ func TestOrgUsers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(OrgUser)}
|
tables := []any{new(OrgUser)}
|
||||||
db := &orgUsers{
|
db := &orgUsers{
|
||||||
DB: dbtest.NewDB(t, "orgUsers", tables...),
|
DB: dbtest.NewDB(t, "orgUsers", tables...),
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ func TestOrgs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(User), new(EmailAddress), new(OrgUser)}
|
tables := []any{new(User), new(EmailAddress), new(OrgUser)}
|
||||||
db := &orgs{
|
db := &orgs{
|
||||||
DB: dbtest.NewDB(t, "orgs", tables...),
|
DB: dbtest.NewDB(t, "orgs", tables...),
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ func TestPerms(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(Access)}
|
tables := []any{new(Access)}
|
||||||
db := &perms{
|
db := &perms{
|
||||||
DB: dbtest.NewDB(t, "perms", tables...),
|
DB: dbtest.NewDB(t, "perms", tables...),
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ func GetUnmergedPullRequest(headRepoID, baseRepoID int64, headBranch, baseBranch
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrPullRequestNotExist{args: map[string]interface{}{
|
return nil, ErrPullRequestNotExist{args: map[string]any{
|
||||||
"headRepoID": headRepoID,
|
"headRepoID": headRepoID,
|
||||||
"baseRepoID": baseRepoID,
|
"baseRepoID": baseRepoID,
|
||||||
"headBranch": headBranch,
|
"headBranch": headBranch,
|
||||||
@ -558,7 +558,7 @@ func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequ
|
|||||||
var _ errutil.NotFound = (*ErrPullRequestNotExist)(nil)
|
var _ errutil.NotFound = (*ErrPullRequestNotExist)(nil)
|
||||||
|
|
||||||
type ErrPullRequestNotExist struct {
|
type ErrPullRequestNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrPullRequestNotExist(err error) bool {
|
func IsErrPullRequestNotExist(err error) bool {
|
||||||
@ -580,7 +580,7 @@ func getPullRequestByID(e Engine, id int64) (*PullRequest, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrPullRequestNotExist{args: map[string]interface{}{"pullRequestID": id}}
|
return nil, ErrPullRequestNotExist{args: map[string]any{"pullRequestID": id}}
|
||||||
}
|
}
|
||||||
return pr, pr.loadAttributes(e)
|
return pr, pr.loadAttributes(e)
|
||||||
}
|
}
|
||||||
@ -598,7 +598,7 @@ func getPullRequestByIssueID(e Engine, issueID int64) (*PullRequest, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrPullRequestNotExist{args: map[string]interface{}{"issueID": issueID}}
|
return nil, ErrPullRequestNotExist{args: map[string]any{"issueID": issueID}}
|
||||||
}
|
}
|
||||||
return pr, pr.loadAttributes(e)
|
return pr, pr.loadAttributes(e)
|
||||||
}
|
}
|
||||||
@ -845,7 +845,7 @@ func TestPullRequests() {
|
|||||||
_ = x.Iterate(PullRequest{
|
_ = x.Iterate(PullRequest{
|
||||||
Status: PULL_REQUEST_STATUS_CHECKING,
|
Status: PULL_REQUEST_STATUS_CHECKING,
|
||||||
},
|
},
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean any) error {
|
||||||
pr := bean.(*PullRequest)
|
pr := bean.(*PullRequest)
|
||||||
|
|
||||||
if err := pr.LoadAttributes(); err != nil {
|
if err := pr.LoadAttributes(); err != nil {
|
||||||
|
@ -209,7 +209,7 @@ func NewRelease(gitRepo *git.Repository, r *Release, uuids []string) error {
|
|||||||
var _ errutil.NotFound = (*ErrReleaseNotExist)(nil)
|
var _ errutil.NotFound = (*ErrReleaseNotExist)(nil)
|
||||||
|
|
||||||
type ErrReleaseNotExist struct {
|
type ErrReleaseNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrReleaseNotExist(err error) bool {
|
func IsErrReleaseNotExist(err error) bool {
|
||||||
@ -231,7 +231,7 @@ func GetRelease(repoID int64, tagName string) (*Release, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return nil, ErrReleaseNotExist{args: map[string]interface{}{"tag": tagName}}
|
return nil, ErrReleaseNotExist{args: map[string]any{"tag": tagName}}
|
||||||
}
|
}
|
||||||
|
|
||||||
r := &Release{RepoID: repoID, LowerTagName: strings.ToLower(tagName)}
|
r := &Release{RepoID: repoID, LowerTagName: strings.ToLower(tagName)}
|
||||||
@ -249,7 +249,7 @@ func GetReleaseByID(id int64) (*Release, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrReleaseNotExist{args: map[string]interface{}{"releaseID": id}}
|
return nil, ErrReleaseNotExist{args: map[string]any{"releaseID": id}}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r, r.LoadAttributes()
|
return r, r.LoadAttributes()
|
||||||
|
@ -1623,7 +1623,7 @@ func DeleteRepository(ownerID, repoID int64) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return ErrRepoNotExist{args: map[string]interface{}{"ownerID": ownerID, "repoID": repoID}}
|
return ErrRepoNotExist{args: map[string]any{"ownerID": ownerID, "repoID": repoID}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case is a organization.
|
// In case is a organization.
|
||||||
@ -1764,7 +1764,7 @@ func GetRepositoryByName(ownerID int64, name string) (*Repository, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrRepoNotExist{args: map[string]interface{}{"ownerID": ownerID, "name": name}}
|
return nil, ErrRepoNotExist{args: map[string]any{"ownerID": ownerID, "name": name}}
|
||||||
}
|
}
|
||||||
return repo, repo.LoadAttributes()
|
return repo, repo.LoadAttributes()
|
||||||
}
|
}
|
||||||
@ -1775,7 +1775,7 @@ func getRepositoryByID(e Engine, id int64) (*Repository, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrRepoNotExist{args: map[string]interface{}{"repoID": id}}
|
return nil, ErrRepoNotExist{args: map[string]any{"repoID": id}}
|
||||||
}
|
}
|
||||||
return repo, repo.loadAttributes(e)
|
return repo, repo.loadAttributes(e)
|
||||||
}
|
}
|
||||||
@ -1909,7 +1909,7 @@ func DeleteOldRepositoryArchives() {
|
|||||||
formats := []string{"zip", "targz"}
|
formats := []string{"zip", "targz"}
|
||||||
oldestTime := time.Now().Add(-conf.Cron.RepoArchiveCleanup.OlderThan)
|
oldestTime := time.Now().Add(-conf.Cron.RepoArchiveCleanup.OlderThan)
|
||||||
if err := x.Where("id > 0").Iterate(new(Repository),
|
if err := x.Where("id > 0").Iterate(new(Repository),
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean any) error {
|
||||||
repo := bean.(*Repository)
|
repo := bean.(*Repository)
|
||||||
basePath := filepath.Join(repo.RepoPath(), "archives")
|
basePath := filepath.Join(repo.RepoPath(), "archives")
|
||||||
for _, format := range formats {
|
for _, format := range formats {
|
||||||
@ -1962,7 +1962,7 @@ func DeleteRepositoryArchives() error {
|
|||||||
defer taskStatusTable.Stop(_CLEAN_OLD_ARCHIVES)
|
defer taskStatusTable.Stop(_CLEAN_OLD_ARCHIVES)
|
||||||
|
|
||||||
return x.Where("id > 0").Iterate(new(Repository),
|
return x.Where("id > 0").Iterate(new(Repository),
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean any) error {
|
||||||
repo := bean.(*Repository)
|
repo := bean.(*Repository)
|
||||||
return os.RemoveAll(filepath.Join(repo.RepoPath(), "archives"))
|
return os.RemoveAll(filepath.Join(repo.RepoPath(), "archives"))
|
||||||
})
|
})
|
||||||
@ -1971,7 +1971,7 @@ func DeleteRepositoryArchives() error {
|
|||||||
func gatherMissingRepoRecords() ([]*Repository, error) {
|
func gatherMissingRepoRecords() ([]*Repository, error) {
|
||||||
repos := make([]*Repository, 0, 10)
|
repos := make([]*Repository, 0, 10)
|
||||||
if err := x.Where("id > 0").Iterate(new(Repository),
|
if err := x.Where("id > 0").Iterate(new(Repository),
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean any) error {
|
||||||
repo := bean.(*Repository)
|
repo := bean.(*Repository)
|
||||||
if !com.IsDir(repo.RepoPath()) {
|
if !com.IsDir(repo.RepoPath()) {
|
||||||
repos = append(repos, repo)
|
repos = append(repos, repo)
|
||||||
@ -2033,7 +2033,7 @@ func ReinitMissingRepositories() error {
|
|||||||
// to make sure the binary and custom conf path are up-to-date.
|
// to make sure the binary and custom conf path are up-to-date.
|
||||||
func SyncRepositoryHooks() error {
|
func SyncRepositoryHooks() error {
|
||||||
return x.Where("id > 0").Iterate(new(Repository),
|
return x.Where("id > 0").Iterate(new(Repository),
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean any) error {
|
||||||
repo := bean.(*Repository)
|
repo := bean.(*Repository)
|
||||||
if err := createDelegateHooks(repo.RepoPath()); err != nil {
|
if err := createDelegateHooks(repo.RepoPath()); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -2067,7 +2067,7 @@ func GitFsck() {
|
|||||||
log.Trace("Doing: GitFsck")
|
log.Trace("Doing: GitFsck")
|
||||||
|
|
||||||
if err := x.Where("id>0").Iterate(new(Repository),
|
if err := x.Where("id>0").Iterate(new(Repository),
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean any) error {
|
||||||
repo := bean.(*Repository)
|
repo := bean.(*Repository)
|
||||||
repoPath := repo.RepoPath()
|
repoPath := repo.RepoPath()
|
||||||
err := git.Fsck(repoPath, git.FsckOptions{
|
err := git.Fsck(repoPath, git.FsckOptions{
|
||||||
@ -2092,7 +2092,7 @@ func GitFsck() {
|
|||||||
func GitGcRepos() error {
|
func GitGcRepos() error {
|
||||||
args := append([]string{"gc"}, conf.Git.GCArgs...)
|
args := append([]string{"gc"}, conf.Git.GCArgs...)
|
||||||
return x.Where("id > 0").Iterate(new(Repository),
|
return x.Where("id > 0").Iterate(new(Repository),
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean any) error {
|
||||||
repo := bean.(*Repository)
|
repo := bean.(*Repository)
|
||||||
if err := repo.GetOwner(); err != nil {
|
if err := repo.GetOwner(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -48,7 +48,7 @@ func GetBranchesByPath(path string) ([]*Branch, error) {
|
|||||||
var _ errutil.NotFound = (*ErrBranchNotExist)(nil)
|
var _ errutil.NotFound = (*ErrBranchNotExist)(nil)
|
||||||
|
|
||||||
type ErrBranchNotExist struct {
|
type ErrBranchNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrBranchNotExist(err error) bool {
|
func IsErrBranchNotExist(err error) bool {
|
||||||
@ -66,7 +66,7 @@ func (ErrBranchNotExist) NotFound() bool {
|
|||||||
|
|
||||||
func (repo *Repository) GetBranch(name string) (*Branch, error) {
|
func (repo *Repository) GetBranch(name string) (*Branch, error) {
|
||||||
if !git.RepoHasBranch(repo.RepoPath(), name) {
|
if !git.RepoHasBranch(repo.RepoPath(), name) {
|
||||||
return nil, ErrBranchNotExist{args: map[string]interface{}{"name": name}}
|
return nil, ErrBranchNotExist{args: map[string]any{"name": name}}
|
||||||
}
|
}
|
||||||
return &Branch{
|
return &Branch{
|
||||||
RepoPath: repo.RepoPath(),
|
RepoPath: repo.RepoPath(),
|
||||||
@ -122,7 +122,7 @@ func GetProtectBranchOfRepoByName(repoID int64, name string) (*ProtectBranch, er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrBranchNotExist{args: map[string]interface{}{"name": name}}
|
return nil, ErrBranchNotExist{args: map[string]any{"name": name}}
|
||||||
}
|
}
|
||||||
return protectBranch, nil
|
return protectBranch, nil
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ func (db *repos) Touch(ctx context.Context, id int64) error {
|
|||||||
return db.WithContext(ctx).
|
return db.WithContext(ctx).
|
||||||
Model(new(Repository)).
|
Model(new(Repository)).
|
||||||
Where("id = ?", id).
|
Where("id = ?", id).
|
||||||
Updates(map[string]interface{}{
|
Updates(map[string]any{
|
||||||
"is_bare": false,
|
"is_bare": false,
|
||||||
"updated_unix": db.NowFunc().Unix(),
|
"updated_unix": db.NowFunc().Unix(),
|
||||||
}).
|
}).
|
||||||
|
@ -85,7 +85,7 @@ func TestRepos(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(Repository)}
|
tables := []any{new(Repository)}
|
||||||
db := &repos{
|
db := &repos{
|
||||||
DB: dbtest.NewDB(t, "repos", tables...),
|
DB: dbtest.NewDB(t, "repos", tables...),
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func generate(dialector gorm.Dialector) ([]*tableInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m := conn.Migrator().(interface {
|
m := conn.Migrator().(interface {
|
||||||
RunWithValue(value interface{}, fc func(*gorm.Statement) error) error
|
RunWithValue(value any, fc func(*gorm.Statement) error) error
|
||||||
FullDataTypeOf(*schema.Field) clause.Expr
|
FullDataTypeOf(*schema.Field) clause.Expr
|
||||||
})
|
})
|
||||||
tableInfos := make([]*tableInfo, 0, len(db.Tables))
|
tableInfos := make([]*tableInfo, 0, len(db.Tables))
|
||||||
|
@ -533,7 +533,7 @@ func RewriteAuthorizedKeys() error {
|
|||||||
}
|
}
|
||||||
defer os.Remove(tmpPath)
|
defer os.Remove(tmpPath)
|
||||||
|
|
||||||
err = x.Iterate(new(PublicKey), func(idx int, bean interface{}) (err error) {
|
err = x.Iterate(new(PublicKey), func(idx int, bean any) (err error) {
|
||||||
_, err = f.WriteString((bean.(*PublicKey)).AuthorizedString())
|
_, err = f.WriteString((bean.(*PublicKey)).AuthorizedString())
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
@ -688,7 +688,7 @@ func AddDeployKey(repoID int64, name, content string) (*DeployKey, error) {
|
|||||||
var _ errutil.NotFound = (*ErrDeployKeyNotExist)(nil)
|
var _ errutil.NotFound = (*ErrDeployKeyNotExist)(nil)
|
||||||
|
|
||||||
type ErrDeployKeyNotExist struct {
|
type ErrDeployKeyNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrDeployKeyNotExist(err error) bool {
|
func IsErrDeployKeyNotExist(err error) bool {
|
||||||
@ -711,7 +711,7 @@ func GetDeployKeyByID(id int64) (*DeployKey, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrDeployKeyNotExist{args: map[string]interface{}{"deployKeyID": id}}
|
return nil, ErrDeployKeyNotExist{args: map[string]any{"deployKeyID": id}}
|
||||||
}
|
}
|
||||||
return key, nil
|
return key, nil
|
||||||
}
|
}
|
||||||
@ -726,7 +726,7 @@ func GetDeployKeyByRepo(keyID, repoID int64) (*DeployKey, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrDeployKeyNotExist{args: map[string]interface{}{"keyID": keyID, "repoID": repoID}}
|
return nil, ErrDeployKeyNotExist{args: map[string]any{"keyID": keyID, "repoID": repoID}}
|
||||||
}
|
}
|
||||||
return key, nil
|
return key, nil
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ func TestTwoFactors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(TwoFactor), new(TwoFactorRecoveryCode)}
|
tables := []any{new(TwoFactor), new(TwoFactorRecoveryCode)}
|
||||||
db := &twoFactors{
|
db := &twoFactors{
|
||||||
DB: dbtest.NewDB(t, "twoFactors", tables...),
|
DB: dbtest.NewDB(t, "twoFactors", tables...),
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func (u *User) AfterSet(colName string, _ xorm.Cell) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// deleteBeans deletes all given beans, beans should contain delete conditions.
|
// deleteBeans deletes all given beans, beans should contain delete conditions.
|
||||||
func deleteBeans(e Engine, beans ...interface{}) (err error) {
|
func deleteBeans(e Engine, beans ...any) (err error) {
|
||||||
for i := range beans {
|
for i := range beans {
|
||||||
if _, err = e.Delete(beans[i]); err != nil {
|
if _, err = e.Delete(beans[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -208,7 +208,7 @@ func getUserByID(e Engine, id int64) (*User, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrUserNotExist{args: map[string]interface{}{"userID": id}}
|
return nil, ErrUserNotExist{args: map[string]any{"userID": id}}
|
||||||
}
|
}
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ func MakeEmailPrimary(userID int64, email *EmailAddress) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return ErrUserNotExist{args: map[string]interface{}{"userID": email.UserID}}
|
return ErrUserNotExist{args: map[string]any{"userID": email.UserID}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the former primary email doesn't disappear.
|
// Make sure the former primary email doesn't disappear.
|
||||||
|
@ -158,7 +158,7 @@ func (db *users) Authenticate(ctx context.Context, login, password string, login
|
|||||||
return user, nil
|
return user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, auth.ErrBadCredentials{Args: map[string]interface{}{"login": login, "userID": user.ID}}
|
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login, "userID": user.ID}}
|
||||||
}
|
}
|
||||||
|
|
||||||
authSourceID = user.LoginSource
|
authSourceID = user.LoginSource
|
||||||
@ -166,7 +166,7 @@ func (db *users) Authenticate(ctx context.Context, login, password string, login
|
|||||||
} else {
|
} else {
|
||||||
// Non-local login source is always greater than 0.
|
// Non-local login source is always greater than 0.
|
||||||
if loginSourceID <= 0 {
|
if loginSourceID <= 0 {
|
||||||
return nil, auth.ErrBadCredentials{Args: map[string]interface{}{"login": login}}
|
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login}}
|
||||||
}
|
}
|
||||||
|
|
||||||
authSourceID = loginSourceID
|
authSourceID = loginSourceID
|
||||||
@ -406,7 +406,7 @@ func (db *users) DeleteCustomAvatar(ctx context.Context, userID int64) error {
|
|||||||
return db.WithContext(ctx).
|
return db.WithContext(ctx).
|
||||||
Model(&User{}).
|
Model(&User{}).
|
||||||
Where("id = ?", userID).
|
Where("id = ?", userID).
|
||||||
Updates(map[string]interface{}{
|
Updates(map[string]any{
|
||||||
"use_custom_avatar": false,
|
"use_custom_avatar": false,
|
||||||
"updated_unix": db.NowFunc().Unix(),
|
"updated_unix": db.NowFunc().Unix(),
|
||||||
}).
|
}).
|
||||||
@ -693,7 +693,7 @@ func (db *users) UseCustomAvatar(ctx context.Context, userID int64, avatar []byt
|
|||||||
return db.WithContext(ctx).
|
return db.WithContext(ctx).
|
||||||
Model(&User{}).
|
Model(&User{}).
|
||||||
Where("id = ?", userID).
|
Where("id = ?", userID).
|
||||||
Updates(map[string]interface{}{
|
Updates(map[string]any{
|
||||||
"use_custom_avatar": true,
|
"use_custom_avatar": true,
|
||||||
"updated_unix": db.NowFunc().Unix(),
|
"updated_unix": db.NowFunc().Unix(),
|
||||||
}).
|
}).
|
||||||
|
@ -82,7 +82,7 @@ func TestUsers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(User), new(EmailAddress), new(Repository), new(Follow), new(PullRequest), new(PublicKey)}
|
tables := []any{new(User), new(EmailAddress), new(Repository), new(Follow), new(PullRequest), new(PublicKey)}
|
||||||
db := &users{
|
db := &users{
|
||||||
DB: dbtest.NewDB(t, "users", tables...),
|
DB: dbtest.NewDB(t, "users", tables...),
|
||||||
}
|
}
|
||||||
@ -134,13 +134,13 @@ func usersAuthenticate(t *testing.T, db *users) {
|
|||||||
|
|
||||||
t.Run("user not found", func(t *testing.T) {
|
t.Run("user not found", func(t *testing.T) {
|
||||||
_, err := db.Authenticate(ctx, "bob", password, -1)
|
_, err := db.Authenticate(ctx, "bob", password, -1)
|
||||||
wantErr := auth.ErrBadCredentials{Args: map[string]interface{}{"login": "bob"}}
|
wantErr := auth.ErrBadCredentials{Args: map[string]any{"login": "bob"}}
|
||||||
assert.Equal(t, wantErr, err)
|
assert.Equal(t, wantErr, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("invalid password", func(t *testing.T) {
|
t.Run("invalid password", func(t *testing.T) {
|
||||||
_, err := db.Authenticate(ctx, alice.Name, "bad_password", -1)
|
_, err := db.Authenticate(ctx, alice.Name, "bad_password", -1)
|
||||||
wantErr := auth.ErrBadCredentials{Args: map[string]interface{}{"login": alice.Name, "userID": alice.ID}}
|
wantErr := auth.ErrBadCredentials{Args: map[string]any{"login": alice.Name, "userID": alice.ID}}
|
||||||
assert.Equal(t, wantErr, err)
|
assert.Equal(t, wantErr, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ func usersAuthenticate(t *testing.T, db *users) {
|
|||||||
t.Run("login source mismatch", func(t *testing.T) {
|
t.Run("login source mismatch", func(t *testing.T) {
|
||||||
_, err := db.Authenticate(ctx, alice.Email, password, 1)
|
_, err := db.Authenticate(ctx, alice.Email, password, 1)
|
||||||
gotErr := fmt.Sprintf("%v", err)
|
gotErr := fmt.Sprintf("%v", err)
|
||||||
wantErr := ErrLoginSourceMismatch{args: map[string]interface{}{"actual": 0, "expect": 1}}.Error()
|
wantErr := ErrLoginSourceMismatch{args: map[string]any{"actual": 0, "expect": 1}}.Error()
|
||||||
assert.Equal(t, wantErr, gotErr)
|
assert.Equal(t, wantErr, gotErr)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ func TestWatches(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []interface{}{new(Watch)}
|
tables := []any{new(Watch)}
|
||||||
db := &watches{
|
db := &watches{
|
||||||
DB: dbtest.NewDB(t, "watches", tables...),
|
DB: dbtest.NewDB(t, "watches", tables...),
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ func CreateWebhook(w *Webhook) error {
|
|||||||
var _ errutil.NotFound = (*ErrWebhookNotExist)(nil)
|
var _ errutil.NotFound = (*ErrWebhookNotExist)(nil)
|
||||||
|
|
||||||
type ErrWebhookNotExist struct {
|
type ErrWebhookNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrWebhookNotExist(err error) bool {
|
func IsErrWebhookNotExist(err error) bool {
|
||||||
@ -264,7 +264,7 @@ func getWebhook(bean *Webhook) (*Webhook, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrWebhookNotExist{args: map[string]interface{}{"webhookID": bean.ID}}
|
return nil, ErrWebhookNotExist{args: map[string]any{"webhookID": bean.ID}}
|
||||||
}
|
}
|
||||||
return bean, nil
|
return bean, nil
|
||||||
}
|
}
|
||||||
@ -494,7 +494,7 @@ func (t *HookTask) AfterSet(colName string, _ xorm.Cell) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *HookTask) ToJSON(v interface{}) string {
|
func (t *HookTask) ToJSON(v any) string {
|
||||||
p, err := jsoniter.Marshal(v)
|
p, err := jsoniter.Marshal(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Marshal [%d]: %v", t.ID, err)
|
log.Error("Marshal [%d]: %v", t.ID, err)
|
||||||
@ -524,7 +524,7 @@ func createHookTask(e Engine, t *HookTask) error {
|
|||||||
var _ errutil.NotFound = (*ErrHookTaskNotExist)(nil)
|
var _ errutil.NotFound = (*ErrHookTaskNotExist)(nil)
|
||||||
|
|
||||||
type ErrHookTaskNotExist struct {
|
type ErrHookTaskNotExist struct {
|
||||||
args map[string]interface{}
|
args map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsHookTaskNotExist(err error) bool {
|
func IsHookTaskNotExist(err error) bool {
|
||||||
@ -550,7 +550,7 @@ func GetHookTaskOfWebhookByUUID(webhookID int64, uuid string) (*HookTask, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if !has {
|
} else if !has {
|
||||||
return nil, ErrHookTaskNotExist{args: map[string]interface{}{"webhookID": webhookID, "uuid": uuid}}
|
return nil, ErrHookTaskNotExist{args: map[string]any{"webhookID": webhookID, "uuid": uuid}}
|
||||||
}
|
}
|
||||||
return hookTask, nil
|
return hookTask, nil
|
||||||
}
|
}
|
||||||
@ -788,7 +788,7 @@ func (t *HookTask) deliver() {
|
|||||||
func DeliverHooks() {
|
func DeliverHooks() {
|
||||||
tasks := make([]*HookTask, 0, 10)
|
tasks := make([]*HookTask, 0, 10)
|
||||||
_ = x.Where("is_delivered = ?", false).Iterate(new(HookTask),
|
_ = x.Where("is_delivered = ?", false).Iterate(new(HookTask),
|
||||||
func(idx int, bean interface{}) error {
|
func(idx int, bean any) error {
|
||||||
t := bean.(*HookTask)
|
t := bean.(*HookTask)
|
||||||
t.deliver()
|
t.deliver()
|
||||||
tasks = append(tasks, t)
|
tasks = append(tasks, t)
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
// NewDB creates a new test database and initializes the given list of tables
|
// NewDB creates a new test database and initializes the given list of tables
|
||||||
// for the suite. The test database is dropped after testing is completed unless
|
// for the suite. The test database is dropped after testing is completed unless
|
||||||
// failed.
|
// failed.
|
||||||
func NewDB(t *testing.T, suite string, tables ...interface{}) *gorm.DB {
|
func NewDB(t *testing.T, suite string, tables ...any) *gorm.DB {
|
||||||
dbType := os.Getenv("GOGS_DATABASE_TYPE")
|
dbType := os.Getenv("GOGS_DATABASE_TYPE")
|
||||||
|
|
||||||
var dbName string
|
var dbName string
|
||||||
|
@ -14,6 +14,6 @@ type Logger struct {
|
|||||||
io.Writer
|
io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Printf(format string, args ...interface{}) {
|
func (l *Logger) Printf(format string, args ...any) {
|
||||||
_, _ = fmt.Fprintf(l.Writer, format, args...)
|
_, _ = fmt.Fprintf(l.Writer, format, args...)
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,13 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// render renders a mail template with given data.
|
// render renders a mail template with given data.
|
||||||
func render(tpl string, data map[string]interface{}) (string, error) {
|
func render(tpl string, data map[string]any) (string, error) {
|
||||||
tplRenderOnce.Do(func() {
|
tplRenderOnce.Do(func() {
|
||||||
opt := &macaron.RenderOptions{
|
opt := &macaron.RenderOptions{
|
||||||
Directory: filepath.Join(conf.WorkDir(), "templates", "mail"),
|
Directory: filepath.Join(conf.WorkDir(), "templates", "mail"),
|
||||||
AppendDirectories: []string{filepath.Join(conf.CustomDir(), "templates", "mail")},
|
AppendDirectories: []string{filepath.Join(conf.CustomDir(), "templates", "mail")},
|
||||||
Extensions: []string{".tmpl", ".html"},
|
Extensions: []string{".tmpl", ".html"},
|
||||||
Funcs: []template.FuncMap{map[string]interface{}{
|
Funcs: []template.FuncMap{map[string]any{
|
||||||
"AppName": func() string {
|
"AppName": func() string {
|
||||||
return conf.App.BrandName
|
return conf.App.BrandName
|
||||||
},
|
},
|
||||||
@ -102,7 +102,7 @@ type Issue interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SendUserMail(_ *macaron.Context, u User, tpl, code, subject, info string) {
|
func SendUserMail(_ *macaron.Context, u User, tpl, code, subject, info string) {
|
||||||
data := map[string]interface{}{
|
data := map[string]any{
|
||||||
"Username": u.DisplayName(),
|
"Username": u.DisplayName(),
|
||||||
"ActiveCodeLives": conf.Auth.ActivateCodeLives / 60,
|
"ActiveCodeLives": conf.Auth.ActivateCodeLives / 60,
|
||||||
"ResetPwdCodeLives": conf.Auth.ResetPasswordCodeLives / 60,
|
"ResetPwdCodeLives": conf.Auth.ResetPasswordCodeLives / 60,
|
||||||
@ -130,7 +130,7 @@ func SendResetPasswordMail(c *macaron.Context, u User) {
|
|||||||
|
|
||||||
// SendActivateAccountMail sends confirmation email.
|
// SendActivateAccountMail sends confirmation email.
|
||||||
func SendActivateEmailMail(c *macaron.Context, u User, email string) {
|
func SendActivateEmailMail(c *macaron.Context, u User, email string) {
|
||||||
data := map[string]interface{}{
|
data := map[string]any{
|
||||||
"Username": u.DisplayName(),
|
"Username": u.DisplayName(),
|
||||||
"ActiveCodeLives": conf.Auth.ActivateCodeLives / 60,
|
"ActiveCodeLives": conf.Auth.ActivateCodeLives / 60,
|
||||||
"Code": u.GenerateEmailActivateCode(email),
|
"Code": u.GenerateEmailActivateCode(email),
|
||||||
@ -150,7 +150,7 @@ func SendActivateEmailMail(c *macaron.Context, u User, email string) {
|
|||||||
|
|
||||||
// SendRegisterNotifyMail triggers a notify e-mail by admin created a account.
|
// SendRegisterNotifyMail triggers a notify e-mail by admin created a account.
|
||||||
func SendRegisterNotifyMail(c *macaron.Context, u User) {
|
func SendRegisterNotifyMail(c *macaron.Context, u User) {
|
||||||
data := map[string]interface{}{
|
data := map[string]any{
|
||||||
"Username": u.DisplayName(),
|
"Username": u.DisplayName(),
|
||||||
}
|
}
|
||||||
body, err := render(MAIL_AUTH_REGISTER_NOTIFY, data)
|
body, err := render(MAIL_AUTH_REGISTER_NOTIFY, data)
|
||||||
@ -169,7 +169,7 @@ func SendRegisterNotifyMail(c *macaron.Context, u User) {
|
|||||||
func SendCollaboratorMail(u, doer User, repo Repository) {
|
func SendCollaboratorMail(u, doer User, repo Repository) {
|
||||||
subject := fmt.Sprintf("%s added you to %s", doer.DisplayName(), repo.FullName())
|
subject := fmt.Sprintf("%s added you to %s", doer.DisplayName(), repo.FullName())
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]any{
|
||||||
"Subject": subject,
|
"Subject": subject,
|
||||||
"RepoName": repo.FullName(),
|
"RepoName": repo.FullName(),
|
||||||
"Link": repo.HTMLURL(),
|
"Link": repo.HTMLURL(),
|
||||||
@ -186,8 +186,8 @@ func SendCollaboratorMail(u, doer User, repo Repository) {
|
|||||||
Send(msg)
|
Send(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func composeTplData(subject, body, link string) map[string]interface{} {
|
func composeTplData(subject, body, link string) map[string]any {
|
||||||
data := make(map[string]interface{}, 10)
|
data := make(map[string]any, 10)
|
||||||
data["Subject"] = subject
|
data["Subject"] = subject
|
||||||
data["Body"] = body
|
data["Body"] = body
|
||||||
data["Link"] = link
|
data["Link"] = link
|
||||||
|
@ -16,4 +16,4 @@ func IsNotFound(err error) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Args is a map of key-value pairs to provide additional context of an error.
|
// Args is a map of key-value pairs to provide additional context of an error.
|
||||||
type Args map[string]interface{}
|
type Args map[string]any
|
||||||
|
@ -26,7 +26,7 @@ func init() {
|
|||||||
IsMatch: func(rule string) bool {
|
IsMatch: func(rule string) bool {
|
||||||
return rule == "AlphaDashDotSlash"
|
return rule == "AlphaDashDotSlash"
|
||||||
},
|
},
|
||||||
IsValid: func(errs binding.Errors, name string, v interface{}) (bool, binding.Errors) {
|
IsValid: func(errs binding.Errors, name string, v any) (bool, binding.Errors) {
|
||||||
if AlphaDashDotSlashPattern.MatchString(fmt.Sprintf("%v", v)) {
|
if AlphaDashDotSlashPattern.MatchString(fmt.Sprintf("%v", v)) {
|
||||||
errs.Add([]string{name}, ERR_ALPHA_DASH_DOT_SLASH, "AlphaDashDotSlash")
|
errs.Add([]string{name}, ERR_ALPHA_DASH_DOT_SLASH, "AlphaDashDotSlash")
|
||||||
return false, errs
|
return false, errs
|
||||||
@ -41,7 +41,7 @@ type Form interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assign assign form values back to the template data.
|
// Assign assign form values back to the template data.
|
||||||
func Assign(form interface{}, data map[string]interface{}) {
|
func Assign(form any, data map[string]any) {
|
||||||
typ := reflect.TypeOf(form)
|
typ := reflect.TypeOf(form)
|
||||||
val := reflect.ValueOf(form)
|
val := reflect.ValueOf(form)
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ func getInclude(field reflect.StructField) string {
|
|||||||
return getRuleBody(field, "Include(")
|
return getRuleBody(field, "Include(")
|
||||||
}
|
}
|
||||||
|
|
||||||
func validate(errs binding.Errors, data map[string]interface{}, f Form, l macaron.Locale) binding.Errors {
|
func validate(errs binding.Errors, data map[string]any, f Form, l macaron.Locale) binding.Errors {
|
||||||
if errs.Len() == 0 {
|
if errs.Len() == 0 {
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ func (r *Request) PostFile(formname, filename string) *Request {
|
|||||||
|
|
||||||
// Body adds request raw body.
|
// Body adds request raw body.
|
||||||
// it supports string and []byte.
|
// it supports string and []byte.
|
||||||
func (r *Request) Body(data interface{}) *Request {
|
func (r *Request) Body(data any) *Request {
|
||||||
switch t := data.(type) {
|
switch t := data.(type) {
|
||||||
case string:
|
case string:
|
||||||
bf := bytes.NewBufferString(t)
|
bf := bytes.NewBufferString(t)
|
||||||
@ -414,7 +414,7 @@ func (r *Request) ToFile(filename string) error {
|
|||||||
|
|
||||||
// ToJson returns the map that marshals from the body bytes as json in response .
|
// ToJson returns the map that marshals from the body bytes as json in response .
|
||||||
// it calls Response inner.
|
// it calls Response inner.
|
||||||
func (r *Request) ToJson(v interface{}) error {
|
func (r *Request) ToJson(v any) error {
|
||||||
data, err := r.Bytes()
|
data, err := r.Bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -424,7 +424,7 @@ func (r *Request) ToJson(v interface{}) error {
|
|||||||
|
|
||||||
// ToXml returns the map that marshals from the body bytes as xml in response .
|
// ToXml returns the map that marshals from the body bytes as xml in response .
|
||||||
// it calls Response inner.
|
// it calls Response inner.
|
||||||
func (r *Request) ToXml(v interface{}) error {
|
func (r *Request) ToXml(v any) error {
|
||||||
data, err := r.Bytes()
|
data, err := r.Bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -161,6 +161,6 @@ func RawMarkdown(body []byte, urlPrefix string) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Markdown takes a string or []byte and renders to HTML in Markdown syntax with special links.
|
// Markdown takes a string or []byte and renders to HTML in Markdown syntax with special links.
|
||||||
func Markdown(input interface{}, urlPrefix string, metas map[string]string) []byte {
|
func Markdown(input any, urlPrefix string, metas map[string]string) []byte {
|
||||||
return Render(TypeMarkdown, input, urlPrefix, metas)
|
return Render(TypeMarkdown, input, urlPrefix, metas)
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ func Detect(filename string) Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render takes a string or []byte and renders to sanitized HTML in given type of syntax with special links.
|
// Render takes a string or []byte and renders to sanitized HTML in given type of syntax with special links.
|
||||||
func Render(typ Type, input interface{}, urlPrefix string, metas map[string]string) []byte {
|
func Render(typ Type, input any, urlPrefix string, metas map[string]string) []byte {
|
||||||
var rawBytes []byte
|
var rawBytes []byte
|
||||||
switch v := input.(type) {
|
switch v := input.(type) {
|
||||||
case []byte:
|
case []byte:
|
||||||
|
@ -35,6 +35,6 @@ func RawOrgMode(body []byte, urlPrefix string) (result []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OrgMode takes a string or []byte and renders to HTML in Org-mode syntax with special links.
|
// OrgMode takes a string or []byte and renders to HTML in Org-mode syntax with special links.
|
||||||
func OrgMode(input interface{}, urlPrefix string, metas map[string]string) []byte {
|
func OrgMode(input any, urlPrefix string, metas map[string]string) []byte {
|
||||||
return Render(TypeOrgMode, input, urlPrefix, metas)
|
return Render(TypeOrgMode, input, urlPrefix, metas)
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ var _ macaron.Locale = (*Locale)(nil)
|
|||||||
|
|
||||||
type Locale struct {
|
type Locale struct {
|
||||||
MockLang string
|
MockLang string
|
||||||
MockTr func(string, ...interface{}) string
|
MockTr func(string, ...any) string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Locale) Language() string {
|
func (l *Locale) Language() string {
|
||||||
return l.MockLang
|
return l.MockLang
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Locale) Tr(format string, args ...interface{}) string {
|
func (l *Locale) Tr(format string, args ...any) string {
|
||||||
return l.MockTr(format, args...)
|
return l.MockTr(format, args...)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func Authentications(c *context.Context) {
|
|||||||
|
|
||||||
type dropdownItem struct {
|
type dropdownItem struct {
|
||||||
Name string
|
Name string
|
||||||
Type interface{}
|
Type any
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -130,7 +130,7 @@ func NewAuthSourcePost(c *context.Context, f form.Authentication) {
|
|||||||
c.Data["SMTPAuths"] = smtp.AuthTypes
|
c.Data["SMTPAuths"] = smtp.AuthTypes
|
||||||
|
|
||||||
hasTLS := false
|
hasTLS := false
|
||||||
var config interface{}
|
var config any
|
||||||
switch auth.Type(f.Type) {
|
switch auth.Type(f.Type) {
|
||||||
case auth.LDAP, auth.DLDAP:
|
case auth.LDAP, auth.DLDAP:
|
||||||
config = parseLDAPConfig(f)
|
config = parseLDAPConfig(f)
|
||||||
@ -284,7 +284,7 @@ func DeleteAuthSource(c *context.Context) {
|
|||||||
} else {
|
} else {
|
||||||
c.Flash.Error(fmt.Sprintf("DeleteSource: %v", err))
|
c.Flash.Error(fmt.Sprintf("DeleteSource: %v", err))
|
||||||
}
|
}
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/admin/auths/" + c.Params(":authid"),
|
"redirect": conf.Server.Subpath + "/admin/auths/" + c.Params(":authid"),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -292,7 +292,7 @@ func DeleteAuthSource(c *context.Context) {
|
|||||||
log.Trace("Authentication deleted by admin(%s): %d", c.User.Name, id)
|
log.Trace("Authentication deleted by admin(%s): %d", c.User.Name, id)
|
||||||
|
|
||||||
c.Flash.Success(c.Tr("admin.auths.deletion_success"))
|
c.Flash.Success(c.Tr("admin.auths.deletion_success"))
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/admin/auths",
|
"redirect": conf.Server.Subpath + "/admin/auths",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func DeleteRepo(c *context.Context) {
|
|||||||
log.Trace("Repository deleted: %s/%s", repo.MustOwner().Name, repo.Name)
|
log.Trace("Repository deleted: %s/%s", repo.MustOwner().Name, repo.Name)
|
||||||
|
|
||||||
c.Flash.Success(c.Tr("repo.settings.deletion_success"))
|
c.Flash.Success(c.Tr("repo.settings.deletion_success"))
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/admin/repos?page=" + c.Query("page"),
|
"redirect": conf.Server.Subpath + "/admin/repos?page=" + c.Query("page"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -230,12 +230,12 @@ func DeleteUser(c *context.Context) {
|
|||||||
switch {
|
switch {
|
||||||
case db.IsErrUserOwnRepos(err):
|
case db.IsErrUserOwnRepos(err):
|
||||||
c.Flash.Error(c.Tr("admin.users.still_own_repo"))
|
c.Flash.Error(c.Tr("admin.users.still_own_repo"))
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/admin/users/" + c.Params(":userid"),
|
"redirect": conf.Server.Subpath + "/admin/users/" + c.Params(":userid"),
|
||||||
})
|
})
|
||||||
case db.IsErrUserHasOrgs(err):
|
case db.IsErrUserHasOrgs(err):
|
||||||
c.Flash.Error(c.Tr("admin.users.still_has_org"))
|
c.Flash.Error(c.Tr("admin.users.still_has_org"))
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/admin/users/" + c.Params(":userid"),
|
"redirect": conf.Server.Subpath + "/admin/users/" + c.Params(":userid"),
|
||||||
})
|
})
|
||||||
default:
|
default:
|
||||||
@ -246,7 +246,7 @@ func DeleteUser(c *context.Context) {
|
|||||||
log.Trace("Account deleted by admin (%s): %s", c.User.Name, u.Name)
|
log.Trace("Account deleted by admin (%s): %s", c.User.Name, u.Name)
|
||||||
|
|
||||||
c.Flash.Success(c.Tr("admin.users.deletion_success"))
|
c.Flash.Success(c.Tr("admin.users.deletion_success"))
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/admin/users",
|
"redirect": conf.Server.Subpath + "/admin/users",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func Search(c *context.APIContext) {
|
|||||||
} else {
|
} else {
|
||||||
u, err := db.Users.GetByID(c.Req.Context(), opts.OwnerID)
|
u, err := db.Users.GetByID(c.Req.Context(), opts.OwnerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, map[string]interface{}{
|
c.JSON(http.StatusInternalServerError, map[string]any{
|
||||||
"ok": false,
|
"ok": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -49,7 +49,7 @@ func Search(c *context.APIContext) {
|
|||||||
|
|
||||||
repos, count, err := db.SearchRepositoryByName(opts)
|
repos, count, err := db.SearchRepositoryByName(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, map[string]interface{}{
|
c.JSON(http.StatusInternalServerError, map[string]any{
|
||||||
"ok": false,
|
"ok": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -57,7 +57,7 @@ func Search(c *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err = db.RepositoryList(repos).LoadAttributes(); err != nil {
|
if err = db.RepositoryList(repos).LoadAttributes(); err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, map[string]interface{}{
|
c.JSON(http.StatusInternalServerError, map[string]any{
|
||||||
"ok": false,
|
"ok": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -70,7 +70,7 @@ func Search(c *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.SetLinkHeader(int(count), opts.PageSize)
|
c.SetLinkHeader(int(count), opts.PageSize)
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": true,
|
"ok": true,
|
||||||
"data": results,
|
"data": results,
|
||||||
})
|
})
|
||||||
|
@ -28,7 +28,7 @@ func Search(c *context.APIContext) {
|
|||||||
|
|
||||||
users, _, err := db.SearchUserByName(opts)
|
users, _, err := db.SearchUserByName(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, map[string]interface{}{
|
c.JSON(http.StatusInternalServerError, map[string]any{
|
||||||
"ok": false,
|
"ok": false,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
@ -48,7 +48,7 @@ func Search(c *context.APIContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": true,
|
"ok": true,
|
||||||
"data": results,
|
"data": results,
|
||||||
})
|
})
|
||||||
|
@ -170,7 +170,7 @@ type responseError struct {
|
|||||||
|
|
||||||
const contentType = "application/vnd.git-lfs+json"
|
const contentType = "application/vnd.git-lfs+json"
|
||||||
|
|
||||||
func responseJSON(w http.ResponseWriter, status int, v interface{}) {
|
func responseJSON(w http.ResponseWriter, status int, v any) {
|
||||||
w.Header().Set("Content-Type", contentType)
|
w.Header().Set("Content-Type", contentType)
|
||||||
w.WriteHeader(status)
|
w.WriteHeader(status)
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ func MembersAction(c *context.Context) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Action(%s): %v", c.Params(":action"), err)
|
log.Error("Action(%s): %v", c.Params(":action"), err)
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": false,
|
"ok": false,
|
||||||
"err": err.Error(),
|
"err": err.Error(),
|
||||||
})
|
})
|
||||||
|
@ -91,7 +91,7 @@ func TeamsAction(c *context.Context) {
|
|||||||
c.Flash.Error(c.Tr("form.last_org_owner"))
|
c.Flash.Error(c.Tr("form.last_org_owner"))
|
||||||
} else {
|
} else {
|
||||||
log.Error("Action(%s): %v", c.Params(":action"), err)
|
log.Error("Action(%s): %v", c.Params(":action"), err)
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": false,
|
"ok": false,
|
||||||
"err": err.Error(),
|
"err": err.Error(),
|
||||||
})
|
})
|
||||||
@ -265,7 +265,7 @@ func DeleteTeam(c *context.Context) {
|
|||||||
c.Flash.Success(c.Tr("org.teams.delete_team_success"))
|
c.Flash.Success(c.Tr("org.teams.delete_team_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": c.Org.OrgLink + "/teams",
|
"redirect": c.Org.OrgLink + "/teams",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -719,7 +719,7 @@ func UpdateIssueTitle(c *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"title": issue.Title,
|
"title": issue.Title,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -778,7 +778,7 @@ func UpdateIssueLabel(c *context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": true,
|
"ok": true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -792,7 +792,7 @@ func UpdateIssueMilestone(c *context.Context) {
|
|||||||
oldMilestoneID := issue.MilestoneID
|
oldMilestoneID := issue.MilestoneID
|
||||||
milestoneID := c.QueryInt64("id")
|
milestoneID := c.QueryInt64("id")
|
||||||
if oldMilestoneID == milestoneID {
|
if oldMilestoneID == milestoneID {
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": true,
|
"ok": true,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -805,7 +805,7 @@ func UpdateIssueMilestone(c *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": true,
|
"ok": true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ func UpdateIssueAssignee(c *context.Context) {
|
|||||||
|
|
||||||
assigneeID := c.QueryInt64("id")
|
assigneeID := c.QueryInt64("id")
|
||||||
if issue.AssigneeID == assigneeID {
|
if issue.AssigneeID == assigneeID {
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": true,
|
"ok": true,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -829,7 +829,7 @@ func UpdateIssueAssignee(c *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"ok": true,
|
"ok": true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -943,7 +943,7 @@ func UpdateCommentContent(c *context.Context) {
|
|||||||
oldContent := comment.Content
|
oldContent := comment.Content
|
||||||
comment.Content = c.Query("content")
|
comment.Content = c.Query("content")
|
||||||
if comment.Content == "" {
|
if comment.Content == "" {
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"content": "",
|
"content": "",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -1062,7 +1062,7 @@ func DeleteLabel(c *context.Context) {
|
|||||||
c.Flash.Success(c.Tr("repo.issues.label_deletion_success"))
|
c.Flash.Success(c.Tr("repo.issues.label_deletion_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": c.Repo.MakeURL("labels"),
|
"redirect": c.Repo.MakeURL("labels"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1260,7 +1260,7 @@ func DeleteMilestone(c *context.Context) {
|
|||||||
c.Flash.Success(c.Tr("repo.milestones.deletion_success"))
|
c.Flash.Success(c.Tr("repo.milestones.deletion_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": c.Repo.MakeURL("milestones"),
|
"redirect": c.Repo.MakeURL("milestones"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ func DeleteRelease(c *context.Context) {
|
|||||||
c.Flash.Success(c.Tr("repo.release.deletion_success"))
|
c.Flash.Success(c.Tr("repo.release.deletion_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": c.Repo.RepoLink + "/releases",
|
"redirect": c.Repo.RepoLink + "/releases",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ func Create(c *context.Context) {
|
|||||||
c.Success(CREATE)
|
c.Success(CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleCreateError(c *context.Context, err error, name, tpl string, form interface{}) {
|
func handleCreateError(c *context.Context, err error, name, tpl string, form any) {
|
||||||
switch {
|
switch {
|
||||||
case db.IsErrReachLimitOfRepo(err):
|
case db.IsErrReachLimitOfRepo(err):
|
||||||
c.RenderWithErr(c.Tr("repo.form.reach_limit_of_creation", err.(db.ErrReachLimitOfRepo).Limit), tpl, form)
|
c.RenderWithErr(c.Tr("repo.form.reach_limit_of_creation", err.(db.ErrReachLimitOfRepo).Limit), tpl, form)
|
||||||
|
@ -429,7 +429,7 @@ func DeleteCollaboration(c *context.Context) {
|
|||||||
c.Flash.Success(c.Tr("repo.settings.remove_collaborator_success"))
|
c.Flash.Success(c.Tr("repo.settings.remove_collaborator_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": c.Repo.RepoLink + "/settings/collaboration",
|
"redirect": c.Repo.RepoLink + "/settings/collaboration",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -682,7 +682,7 @@ func DeleteDeployKey(c *context.Context) {
|
|||||||
c.Flash.Success(c.Tr("repo.settings.deploy_key_deletion_success"))
|
c.Flash.Success(c.Tr("repo.settings.deploy_key_deletion_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": c.Repo.RepoLink + "/settings/keys",
|
"redirect": c.Repo.RepoLink + "/settings/keys",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -591,7 +591,7 @@ func DeleteWebhook(c *context.Context, orCtx *orgRepoContext) {
|
|||||||
}
|
}
|
||||||
c.Flash.Success(c.Tr("repo.settings.webhook_deletion_success"))
|
c.Flash.Success(c.Tr("repo.settings.webhook_deletion_success"))
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": orCtx.Link + "/settings/hooks",
|
"redirect": orCtx.Link + "/settings/hooks",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
func Test_validateWebhook(t *testing.T) {
|
func Test_validateWebhook(t *testing.T) {
|
||||||
l := &mocks.Locale{
|
l := &mocks.Locale{
|
||||||
MockLang: "en",
|
MockLang: "en",
|
||||||
MockTr: func(s string, _ ...interface{}) string {
|
MockTr: func(s string, _ ...any) string {
|
||||||
return s
|
return s
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ func DeleteWikiPagePost(c *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": c.Repo.RepoLink + "/wiki/",
|
"redirect": c.Repo.RepoLink + "/wiki/",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ func DeleteEmail(c *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Flash.Success(c.Tr("settings.email_deletion_success"))
|
c.Flash.Success(c.Tr("settings.email_deletion_success"))
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/user/settings/email",
|
"redirect": conf.Server.Subpath + "/user/settings/email",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ func DeleteSSHKey(c *context.Context) {
|
|||||||
c.Flash.Success(c.Tr("settings.ssh_key_deletion_success"))
|
c.Flash.Success(c.Tr("settings.ssh_key_deletion_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/user/settings/ssh",
|
"redirect": conf.Server.Subpath + "/user/settings/ssh",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -507,7 +507,7 @@ func SettingsTwoFactorDisable(c *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Flash.Success(c.Tr("settings.two_factor_disable_success"))
|
c.Flash.Success(c.Tr("settings.two_factor_disable_success"))
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/user/settings/security",
|
"redirect": conf.Server.Subpath + "/user/settings/security",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ func SettingsLeaveRepo(c *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Flash.Success(c.Tr("settings.repos.leave_success", repo.FullName()))
|
c.Flash.Success(c.Tr("settings.repos.leave_success", repo.FullName()))
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/user/settings/repositories",
|
"redirect": conf.Server.Subpath + "/user/settings/repositories",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -572,7 +572,7 @@ func SettingsLeaveOrganization(c *context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/user/settings/organizations",
|
"redirect": conf.Server.Subpath + "/user/settings/organizations",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ func SettingsDeleteApplication(c *context.Context) {
|
|||||||
c.Flash.Success(c.Tr("settings.delete_token_success"))
|
c.Flash.Success(c.Tr("settings.delete_token_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSONSuccess(map[string]interface{}{
|
c.JSONSuccess(map[string]any{
|
||||||
"redirect": conf.Server.Subpath + "/user/settings/applications",
|
"redirect": conf.Server.Subpath + "/user/settings/applications",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,13 @@ func (q *UniqueQueue) Queue() <-chan string {
|
|||||||
|
|
||||||
// Exist returns true if there is an instance with given indentity
|
// Exist returns true if there is an instance with given indentity
|
||||||
// exists in the queue.
|
// exists in the queue.
|
||||||
func (q *UniqueQueue) Exist(id interface{}) bool {
|
func (q *UniqueQueue) Exist(id any) bool {
|
||||||
return q.table.IsRunning(com.ToStr(id))
|
return q.table.IsRunning(com.ToStr(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddFunc adds new instance to the queue with a custom runnable function,
|
// AddFunc adds new instance to the queue with a custom runnable function,
|
||||||
// the queue is blocked until the function exits.
|
// the queue is blocked until the function exits.
|
||||||
func (q *UniqueQueue) AddFunc(id interface{}, fn func()) {
|
func (q *UniqueQueue) AddFunc(id any, fn func()) {
|
||||||
if q.Exist(id) {
|
if q.Exist(id) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -60,11 +60,11 @@ func (q *UniqueQueue) AddFunc(id interface{}, fn func()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add adds new instance to the queue.
|
// Add adds new instance to the queue.
|
||||||
func (q *UniqueQueue) Add(id interface{}) {
|
func (q *UniqueQueue) Add(id any) {
|
||||||
q.AddFunc(id, nil)
|
q.AddFunc(id, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove removes instance from the queue.
|
// Remove removes instance from the queue.
|
||||||
func (q *UniqueQueue) Remove(id interface{}) {
|
func (q *UniqueQueue) Remove(id any) {
|
||||||
q.table.Stop(com.ToStr(id))
|
q.table.Stop(com.ToStr(id))
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ var (
|
|||||||
// FuncMap returns a list of user-defined template functions.
|
// FuncMap returns a list of user-defined template functions.
|
||||||
func FuncMap() []template.FuncMap {
|
func FuncMap() []template.FuncMap {
|
||||||
funcMapOnce.Do(func() {
|
funcMapOnce.Do(func() {
|
||||||
funcMap = []template.FuncMap{map[string]interface{}{
|
funcMap = []template.FuncMap{map[string]any{
|
||||||
"BuildCommit": func() string {
|
"BuildCommit": func() string {
|
||||||
return conf.BuildCommit
|
return conf.BuildCommit
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,7 @@ func Update(name string) bool {
|
|||||||
|
|
||||||
// AssertGolden compares what's got and what's in the golden file. It updates
|
// AssertGolden compares what's got and what's in the golden file. It updates
|
||||||
// the golden file on-demand. It does nothing when the runtime is "windows".
|
// the golden file on-demand. It does nothing when the runtime is "windows".
|
||||||
func AssertGolden(t testing.TB, path string, update bool, got interface{}) {
|
func AssertGolden(t testing.TB, path string, update bool, got any) {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
t.Skip("Skipping testing on Windows")
|
t.Skip("Skipping testing on Windows")
|
||||||
return
|
return
|
||||||
@ -59,7 +59,7 @@ func AssertGolden(t testing.TB, path string, update bool, got interface{}) {
|
|||||||
assert.Equal(t, string(golden), string(data))
|
assert.Equal(t, string(golden), string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshal(t testing.TB, v interface{}) []byte {
|
func marshal(t testing.TB, v any) []byte {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
switch v2 := v.(type) {
|
switch v2 := v.(type) {
|
||||||
|
@ -26,6 +26,6 @@ func (*noopLogger) Write(log.Messager) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InitNoopLogger is a init function to initialize a noop logger.
|
// InitNoopLogger is a init function to initialize a noop logger.
|
||||||
var InitNoopLogger = func(name string, vs ...interface{}) (log.Logger, error) {
|
var InitNoopLogger = func(name string, vs ...any) (log.Logger, error) {
|
||||||
return &noopLogger{}, nil
|
return &noopLogger{}, nil
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ const TIME_LIMIT_CODE_LENGTH = 12 + 6 + 40
|
|||||||
|
|
||||||
// CreateTimeLimitCode generates a time limit code based on given input data.
|
// CreateTimeLimitCode generates a time limit code based on given input data.
|
||||||
// Format: 12 length date time string + 6 minutes string + 40 sha1 encoded string
|
// Format: 12 length date time string + 6 minutes string + 40 sha1 encoded string
|
||||||
func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string {
|
func CreateTimeLimitCode(data string, minutes int, startInf any) string {
|
||||||
format := "200601021504"
|
format := "200601021504"
|
||||||
|
|
||||||
var start, end time.Time
|
var start, end time.Time
|
||||||
@ -306,7 +306,7 @@ func TimeSince(t time.Time, lang string) template.HTML {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Subtract deals with subtraction of all types of number.
|
// Subtract deals with subtraction of all types of number.
|
||||||
func Subtract(left, right interface{}) interface{} {
|
func Subtract(left, right any) any {
|
||||||
var rleft, rright int64
|
var rleft, rright int64
|
||||||
var fleft, fright float64
|
var fleft, fright float64
|
||||||
isInt := true
|
isInt := true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user