diff --git a/.deadcode-out b/.deadcode-out
index f9bee43043..61c5bcb055 100644
--- a/.deadcode-out
+++ b/.deadcode-out
@@ -27,13 +27,15 @@ forgejo.org/models/db
TruncateBeans
InTransaction
DumpTables
- GetTableNames
forgejo.org/models/dbfs
file.renameTo
Create
Rename
+forgejo.org/models/forgefed
+ GetFederationHost
+
forgejo.org/models/forgejo/semver
GetVersion
SetVersionString
@@ -65,6 +67,7 @@ forgejo.org/models/user
DeleteUserSetting
GetFederatedUser
GetFederatedUserByUserID
+ UpdateFederatedUser
GetFollowersForUser
AddFollower
RemoveFollower
@@ -245,9 +248,6 @@ forgejo.org/routers/web/org
forgejo.org/services/context
GetPrivateContext
-forgejo.org/services/federation
- Init
-
forgejo.org/services/repository
IsErrForkAlreadyExist
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 3f250e5682..28fa9e4555 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -6,7 +6,7 @@
"ghcr.io/devcontainers/features/node:1": {
"version": "22"
},
- "ghcr.io/devcontainers/features/git-lfs:1.2.5": {},
+ "ghcr.io/devcontainers/features/git-lfs:1.2.4": {},
"ghcr.io/warrenbuckley/codespace-features/sqlite:1": {}
},
"customizations": {
diff --git a/.forgejo/workflows/renovate.yml b/.forgejo/workflows/renovate.yml
index d3eac5357a..729cba3723 100644
--- a/.forgejo/workflows/renovate.yml
+++ b/.forgejo/workflows/renovate.yml
@@ -28,7 +28,7 @@ jobs:
runs-on: docker
container:
- image: data.forgejo.org/renovate/renovate:41.23.2
+ image: data.forgejo.org/renovate/renovate:41.17.2
steps:
- name: Load renovate repo cache
diff --git a/.golangci.yml b/.golangci.yml
index 6679a1850e..532132838d 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -79,10 +79,6 @@ linters:
- name: unreachable-code
- name: var-declaration
- name: var-naming
- arguments:
- - []
- - []
- - - skip-package-name-checks: true
- name: redefines-builtin-id
disabled: true
staticcheck:
diff --git a/Makefile b/Makefile
index c09e0180eb..db4ec2fbd5 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ XGO_VERSION := go-1.21.x
AIR_PACKAGE ?= github.com/air-verse/air@v1 # renovate: datasource=go
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.3.0 # renovate: datasource=go
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.8.0 # renovate: datasource=go
-GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.1 # renovate: datasource=go
+GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 # renovate: datasource=go
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11 # renovate: datasource=go
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0 # renovate: datasource=go
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
@@ -47,7 +47,7 @@ GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0 # renovate: datasour
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 # renovate: datasource=go
DEADCODE_PACKAGE ?= golang.org/x/tools/cmd/deadcode@v0.34.0 # renovate: datasource=go
GOMOCK_PACKAGE ?= go.uber.org/mock/mockgen@v0.5.2 # renovate: datasource=go
-RENOVATE_NPM_PACKAGE ?= renovate@41.23.2 # renovate: datasource=docker packageName=data.forgejo.org/renovate/renovate
+RENOVATE_NPM_PACKAGE ?= renovate@41.17.2 # renovate: datasource=docker packageName=data.forgejo.org/renovate/renovate
# https://github.com/disposable-email-domains/disposable-email-domains/commits/main/
DISPOSABLE_EMAILS_SHA ?= 0c27e671231d27cf66370034d7f6818037416989 # renovate: ...
diff --git a/cmd/admin_auth.go b/cmd/admin_auth.go
index 91b344b1e9..cb95b3b3c8 100644
--- a/cmd/admin_auth.go
+++ b/cmd/admin_auth.go
@@ -17,15 +17,6 @@ import (
"github.com/urfave/cli/v3"
)
-type (
- authService struct {
- initDB func(ctx context.Context) error
- createAuthSource func(context.Context, *auth_model.Source) error
- updateAuthSource func(context.Context, *auth_model.Source) error
- getAuthSourceByID func(ctx context.Context, id int64) (*auth_model.Source, error)
- }
-)
-
func microcmdAuthDelete() *cli.Command {
return &cli.Command{
Name: "delete",
@@ -69,16 +60,6 @@ func microcmdAuthList() *cli.Command {
}
}
-// newAuthService creates a service with default functions.
-func newAuthService() *authService {
- return &authService{
- initDB: initDB,
- createAuthSource: auth_model.CreateSource,
- updateAuthSource: auth_model.UpdateSource,
- getAuthSourceByID: auth_model.GetSourceByID,
- }
-}
-
func runListAuth(ctx context.Context, c *cli.Command) error {
ctx, cancel := installSignals(ctx)
defer cancel()
diff --git a/cmd/admin_auth_ldap.go b/cmd/admin_auth_ldap.go
index 9af6c331d3..997d6b3a16 100644
--- a/cmd/admin_auth_ldap.go
+++ b/cmd/admin_auth_ldap.go
@@ -14,6 +14,15 @@ import (
"github.com/urfave/cli/v3"
)
+type (
+ authService struct {
+ initDB func(ctx context.Context) error
+ createAuthSource func(context.Context, *auth.Source) error
+ updateAuthSource func(context.Context, *auth.Source) error
+ getAuthSourceByID func(ctx context.Context, id int64) (*auth.Source, error)
+ }
+)
+
func commonLdapCLIFlags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
@@ -175,6 +184,16 @@ func microcmdAuthUpdateLdapSimpleAuth() *cli.Command {
}
}
+// newAuthService creates a service with default functions.
+func newAuthService() *authService {
+ return &authService{
+ initDB: initDB,
+ createAuthSource: auth.CreateSource,
+ updateAuthSource: auth.UpdateSource,
+ getAuthSourceByID: auth.GetSourceByID,
+ }
+}
+
// parseAuthSource assigns values on authSource according to command line flags.
func parseAuthSource(c *cli.Command, authSource *auth.Source) {
if c.IsSet("name") {
diff --git a/cmd/admin_auth_oauth.go b/cmd/admin_auth_oauth.go
index 8a756480cd..abdcd5d48a 100644
--- a/cmd/admin_auth_oauth.go
+++ b/cmd/admin_auth_oauth.go
@@ -86,11 +86,6 @@ func oauthCLIFlags() []cli.Flag {
Value: nil,
Usage: "Scopes to request when to authenticate against this OAuth2 source",
},
- &cli.StringFlag{
- Name: "attribute-ssh-public-key",
- Value: "",
- Usage: "Claim name providing SSH public keys for this source",
- },
&cli.StringFlag{
Name: "required-claim-name",
Value: "",
@@ -132,7 +127,7 @@ func microcmdAuthAddOauth() *cli.Command {
return &cli.Command{
Name: "add-oauth",
Usage: "Add new Oauth authentication source",
- Action: newAuthService().addOauth,
+ Action: runAddOauth,
Flags: oauthCLIFlags(),
}
}
@@ -141,7 +136,7 @@ func microcmdAuthUpdateOauth() *cli.Command {
return &cli.Command{
Name: "update-oauth",
Usage: "Update existing Oauth authentication source",
- Action: newAuthService().updateOauth,
+ Action: runUpdateOauth,
Flags: append(oauthCLIFlags()[:1], append([]cli.Flag{idFlag()}, oauthCLIFlags()[1:]...)...),
}
}
@@ -168,7 +163,6 @@ func parseOAuth2Config(_ context.Context, c *cli.Command) *oauth2.Source {
IconURL: c.String("icon-url"),
SkipLocalTwoFA: c.Bool("skip-local-2fa"),
Scopes: c.StringSlice("scopes"),
- AttributeSSHPublicKey: c.String("attribute-ssh-public-key"),
RequiredClaimName: c.String("required-claim-name"),
RequiredClaimValue: c.String("required-claim-value"),
GroupClaimName: c.String("group-claim-name"),
@@ -179,11 +173,11 @@ func parseOAuth2Config(_ context.Context, c *cli.Command) *oauth2.Source {
}
}
-func (a *authService) addOauth(ctx context.Context, c *cli.Command) error {
+func runAddOauth(ctx context.Context, c *cli.Command) error {
ctx, cancel := installSignals(ctx)
defer cancel()
- if err := a.initDB(ctx); err != nil {
+ if err := initDB(ctx); err != nil {
return err
}
@@ -195,7 +189,7 @@ func (a *authService) addOauth(ctx context.Context, c *cli.Command) error {
}
}
- return a.createAuthSource(ctx, &auth_model.Source{
+ return auth_model.CreateSource(ctx, &auth_model.Source{
Type: auth_model.OAuth2,
Name: c.String("name"),
IsActive: true,
@@ -203,7 +197,7 @@ func (a *authService) addOauth(ctx context.Context, c *cli.Command) error {
})
}
-func (a *authService) updateOauth(ctx context.Context, c *cli.Command) error {
+func runUpdateOauth(ctx context.Context, c *cli.Command) error {
if !c.IsSet("id") {
return errors.New("--id flag is missing")
}
@@ -211,11 +205,11 @@ func (a *authService) updateOauth(ctx context.Context, c *cli.Command) error {
ctx, cancel := installSignals(ctx)
defer cancel()
- if err := a.initDB(ctx); err != nil {
+ if err := initDB(ctx); err != nil {
return err
}
- source, err := a.getAuthSourceByID(ctx, c.Int64("id"))
+ source, err := auth_model.GetSourceByID(ctx, c.Int64("id"))
if err != nil {
return err
}
@@ -250,10 +244,6 @@ func (a *authService) updateOauth(ctx context.Context, c *cli.Command) error {
oAuth2Config.Scopes = c.StringSlice("scopes")
}
- if c.IsSet("attribute-ssh-public-key") {
- oAuth2Config.AttributeSSHPublicKey = c.String("attribute-ssh-public-key")
- }
-
if c.IsSet("required-claim-name") {
oAuth2Config.RequiredClaimName = c.String("required-claim-name")
}
@@ -310,5 +300,5 @@ func (a *authService) updateOauth(ctx context.Context, c *cli.Command) error {
oAuth2Config.CustomURLMapping = customURLMapping
source.Cfg = oAuth2Config
- return a.updateAuthSource(ctx, source)
+ return auth_model.UpdateSource(ctx, source)
}
diff --git a/cmd/admin_auth_oauth_test.go b/cmd/admin_auth_oauth_test.go
deleted file mode 100644
index ea5442e62d..0000000000
--- a/cmd/admin_auth_oauth_test.go
+++ /dev/null
@@ -1,704 +0,0 @@
-// Copyright 2025 The Forgejo Authors. All rights reserved.
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-package cmd
-
-import (
- "context"
- "testing"
-
- "forgejo.org/models/auth"
- "forgejo.org/modules/test"
- "forgejo.org/services/auth/source/oauth2"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "github.com/urfave/cli/v3"
-)
-
-func TestAddOauth(t *testing.T) {
- // Mock cli functions to do not exit on error
- defer test.MockVariableValue(&cli.OsExiter, func(code int) {})()
-
- // Test cases
- cases := []struct {
- args []string
- source *auth.Source
- errMsg string
- }{
- // case 0
- {
- args: []string{
- "oauth-test",
- "--name", "oauth2 (via openidConnect) source full",
- "--provider", "openidConnect",
- "--key", "client id",
- "--secret", "client secret",
- "--auto-discover-url", "https://example.com/.well-known/openid-configuration",
- "--use-custom-urls", "",
- "--custom-tenant-id", "tenant id",
- "--custom-auth-url", "https://example.com/auth",
- "--custom-token-url", "https://example.com/token",
- "--custom-profile-url", "https://example.com/profile",
- "--custom-email-url", "https://example.com/email",
- "--icon-url", "https://example.com/icon.svg",
- "--skip-local-2fa",
- "--scopes", "address",
- "--scopes", "email",
- "--scopes", "phone",
- "--scopes", "profile",
- "--attribute-ssh-public-key", "ssh_public_key",
- "--required-claim-name", "can_access",
- "--required-claim-value", "yes",
- "--group-claim-name", "groups",
- "--admin-group", "admin",
- "--restricted-group", "restricted",
- "--group-team-map", `{"org_a_team_1": {"organization-a": ["Team 1"]}, "org_a_all_teams": {"organization-a": ["Team 1", "Team 2", "Team 3"]}}`,
- "--group-team-map-removal",
- },
- source: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source full",
- IsActive: true,
- Cfg: &oauth2.Source{
- Provider: "openidConnect",
- ClientID: "client id",
- ClientSecret: "client secret",
- OpenIDConnectAutoDiscoveryURL: "https://example.com/.well-known/openid-configuration",
- CustomURLMapping: &oauth2.CustomURLMapping{
- AuthURL: "https://example.com/auth",
- TokenURL: "https://example.com/token",
- ProfileURL: "https://example.com/profile",
- EmailURL: "https://example.com/email",
- Tenant: "tenant id",
- },
- IconURL: "https://example.com/icon.svg",
- Scopes: []string{"address", "email", "phone", "profile"},
- AttributeSSHPublicKey: "ssh_public_key",
- RequiredClaimName: "can_access",
- RequiredClaimValue: "yes",
- GroupClaimName: "groups",
- AdminGroup: "admin",
- GroupTeamMap: `{"org_a_team_1": {"organization-a": ["Team 1"]}, "org_a_all_teams": {"organization-a": ["Team 1", "Team 2", "Team 3"]}}`,
- GroupTeamMapRemoval: true,
- RestrictedGroup: "restricted",
- SkipLocalTwoFA: true,
- },
- },
- },
- // case 1
- {
- args: []string{
- "oauth-test",
- "--name", "oauth2 (via openidConnect) source min",
- "--provider", "openidConnect",
- "--auto-discover-url", "https://example.com/.well-known/openid-configuration",
- },
- source: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source min",
- IsActive: true,
- Cfg: &oauth2.Source{
- Provider: "openidConnect",
- OpenIDConnectAutoDiscoveryURL: "https://example.com/.well-known/openid-configuration",
- Scopes: []string{},
- },
- },
- },
- // case 2
- {
- args: []string{
- "oauth-test",
- "--name", "oauth2 (via openidConnect) source `--use-custom-urls` required for `--custom-*` flags",
- "--custom-tenant-id", "tenant id",
- "--custom-auth-url", "https://example.com/auth",
- "--custom-token-url", "https://example.com/token",
- "--custom-profile-url", "https://example.com/profile",
- "--custom-email-url", "https://example.com/email",
- },
- source: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source `--use-custom-urls` required for `--custom-*` flags",
- IsActive: true,
- Cfg: &oauth2.Source{
- Scopes: []string{},
- },
- },
- },
- // case 3
- {
- args: []string{
- "oauth-test",
- "--name", "oauth2 (via openidConnect) source `--scopes` aggregates multiple uses",
- "--provider", "openidConnect",
- "--auto-discover-url", "https://example.com/.well-known/openid-configuration",
- "--scopes", "address",
- "--scopes", "email",
- "--scopes", "phone",
- "--scopes", "profile",
- },
- source: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source `--scopes` aggregates multiple uses",
- IsActive: true,
- Cfg: &oauth2.Source{
- Provider: "openidConnect",
- OpenIDConnectAutoDiscoveryURL: "https://example.com/.well-known/openid-configuration",
- Scopes: []string{"address", "email", "phone", "profile"},
- },
- },
- },
- // case 4
- {
- args: []string{
- "oauth-test",
- "--name", "oauth2 (via openidConnect) source `--scopes` supports commas as separators",
- "--provider", "openidConnect",
- "--auto-discover-url", "https://example.com/.well-known/openid-configuration",
- "--scopes", "address,email,phone,profile",
- },
- source: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source `--scopes` supports commas as separators",
- IsActive: true,
- Cfg: &oauth2.Source{
- Provider: "openidConnect",
- OpenIDConnectAutoDiscoveryURL: "https://example.com/.well-known/openid-configuration",
- Scopes: []string{"address", "email", "phone", "profile"},
- },
- },
- },
- // case 5
- {
- args: []string{
- "oauth-test",
- "--name", "oauth2 (via openidConnect) source",
- "--provider", "openidConnect",
- },
- errMsg: "invalid Auto Discovery URL: (this must be a valid URL starting with http:// or https://)",
- },
- // case 6
- {
- args: []string{
- "oauth-test",
- "--name", "oauth2 (via openidConnect) source",
- "--provider", "openidConnect",
- "--auto-discover-url", "example.com",
- },
- errMsg: "invalid Auto Discovery URL: example.com (this must be a valid URL starting with http:// or https://)",
- },
- }
-
- for n, c := range cases {
- // Mock functions.
- var createdAuthSource *auth.Source
- service := &authService{
- initDB: func(context.Context) error {
- return nil
- },
- createAuthSource: func(ctx context.Context, authSource *auth.Source) error {
- createdAuthSource = authSource
- return nil
- },
- updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
- assert.FailNow(t, "should not call updateAuthSource", "case: %d", n)
- return nil
- },
- getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
- assert.FailNow(t, "should not call getAuthSourceByID", "case: %d", n)
- return nil, nil
- },
- }
-
- // Create a copy of command to test
- app := cli.Command{}
- app.Flags = microcmdAuthAddOauth().Flags
- app.Action = service.addOauth
-
- // Run it
- err := app.Run(t.Context(), c.args)
- if c.errMsg != "" {
- assert.EqualError(t, err, c.errMsg, "case %d: error should match", n)
- } else {
- require.NoError(t, err, "case %d: should have no errors", n)
- assert.Equal(t, c.source, createdAuthSource, "case %d: wrong authSource", n)
- }
- }
-}
-
-func TestUpdateOauth(t *testing.T) {
- // Mock cli functions to do not exit on error
- defer test.MockVariableValue(&cli.OsExiter, func(code int) {})()
-
- // Test cases
- cases := []struct {
- args []string
- id int64
- existingAuthSource *auth.Source
- authSource *auth.Source
- errMsg string
- }{
- // case 0
- {
- args: []string{
- "oauth-test",
- "--id", "23",
- "--name", "oauth2 (via openidConnect) source full",
- "--provider", "openidConnect",
- "--key", "client id",
- "--secret", "client secret",
- "--auto-discover-url", "https://example.com/.well-known/openid-configuration",
- "--use-custom-urls", "",
- "--custom-tenant-id", "tenant id",
- "--custom-auth-url", "https://example.com/auth",
- "--custom-token-url", "https://example.com/token",
- "--custom-profile-url", "https://example.com/profile",
- "--custom-email-url", "https://example.com/email",
- "--icon-url", "https://example.com/icon.svg",
- "--skip-local-2fa",
- "--scopes", "address",
- "--scopes", "email",
- "--scopes", "phone",
- "--scopes", "profile",
- "--attribute-ssh-public-key", "ssh_public_key",
- "--required-claim-name", "can_access",
- "--required-claim-value", "yes",
- "--group-claim-name", "groups",
- "--admin-group", "admin",
- "--restricted-group", "restricted",
- "--group-team-map", `{"org_a_team_1": {"organization-a": ["Team 1"]}, "org_a_all_teams": {"organization-a": ["Team 1", "Team 2", "Team 3"]}}`,
- "--group-team-map-removal",
- },
- id: 23,
- existingAuthSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{},
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source full",
- Cfg: &oauth2.Source{
- Provider: "openidConnect",
- ClientID: "client id",
- ClientSecret: "client secret",
- OpenIDConnectAutoDiscoveryURL: "https://example.com/.well-known/openid-configuration",
- CustomURLMapping: &oauth2.CustomURLMapping{
- AuthURL: "https://example.com/auth",
- TokenURL: "https://example.com/token",
- ProfileURL: "https://example.com/profile",
- EmailURL: "https://example.com/email",
- Tenant: "tenant id",
- },
- IconURL: "https://example.com/icon.svg",
- Scopes: []string{"address", "email", "phone", "profile"},
- AttributeSSHPublicKey: "ssh_public_key",
- RequiredClaimName: "can_access",
- RequiredClaimValue: "yes",
- GroupClaimName: "groups",
- AdminGroup: "admin",
- GroupTeamMap: `{"org_a_team_1": {"organization-a": ["Team 1"]}, "org_a_all_teams": {"organization-a": ["Team 1", "Team 2", "Team 3"]}}`,
- GroupTeamMapRemoval: true,
- RestrictedGroup: "restricted",
- // `--skip-local-2fa` is currently ignored.
- // SkipLocalTwoFA: true,
- },
- },
- },
- // case 1
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- },
- },
- },
- // case 2
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--name", "oauth2 (via openidConnect) source full",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source full",
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- },
- },
- },
- // case 3
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--provider", "openidConnect",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- Provider: "openidConnect",
- CustomURLMapping: &oauth2.CustomURLMapping{},
- },
- },
- },
- // case 4
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--key", "client id",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- ClientID: "client id",
- CustomURLMapping: &oauth2.CustomURLMapping{},
- },
- },
- },
- // case 5
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--secret", "client secret",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- ClientSecret: "client secret",
- CustomURLMapping: &oauth2.CustomURLMapping{},
- },
- },
- },
- // case 6
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--auto-discover-url", "https://example.com/.well-known/openid-configuration",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- OpenIDConnectAutoDiscoveryURL: "https://example.com/.well-known/openid-configuration",
- CustomURLMapping: &oauth2.CustomURLMapping{},
- },
- },
- },
- // case 7
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--use-custom-urls", "",
- "--custom-tenant-id", "tenant id",
- "--custom-auth-url", "https://example.com/auth",
- "--custom-token-url", "https://example.com/token",
- "--custom-profile-url", "https://example.com/profile",
- "--custom-email-url", "https://example.com/email",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{
- AuthURL: "https://example.com/auth",
- TokenURL: "https://example.com/token",
- ProfileURL: "https://example.com/profile",
- EmailURL: "https://example.com/email",
- Tenant: "tenant id",
- },
- },
- },
- },
- // case 8
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--name", "oauth2 (via openidConnect) source `--use-custom-urls` required for `--custom-*` flags",
- "--custom-tenant-id", "tenant id",
- "--custom-auth-url", "https://example.com/auth",
- "--custom-token-url", "https://example.com/token",
- "--custom-profile-url", "https://example.com/profile",
- "--custom-email-url", "https://example.com/email",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source `--use-custom-urls` required for `--custom-*` flags",
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- },
- },
- },
- // case 9
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--icon-url", "https://example.com/icon.svg",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- IconURL: "https://example.com/icon.svg",
- },
- },
- },
- // case 10
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--name", "oauth2 (via openidConnect) source `--skip-local-2fa` is currently ignored",
- "--skip-local-2fa",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source `--skip-local-2fa` is currently ignored",
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- // `--skip-local-2fa` is currently ignored.
- // SkipLocalTwoFA: true,
- },
- },
- },
- // case 11
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--name", "oauth2 (via openidConnect) source `--scopes` aggregates multiple uses",
- "--scopes", "address",
- "--scopes", "email",
- "--scopes", "phone",
- "--scopes", "profile",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source `--scopes` aggregates multiple uses",
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- Scopes: []string{"address", "email", "phone", "profile"},
- },
- },
- },
- // case 12
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--name", "oauth2 (via openidConnect) source `--scopes` supports commas as separators",
- "--scopes", "address,email,phone,profile",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Name: "oauth2 (via openidConnect) source `--scopes` supports commas as separators",
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- Scopes: []string{"address", "email", "phone", "profile"},
- },
- },
- },
- // case 13
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--attribute-ssh-public-key", "ssh_public_key",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- AttributeSSHPublicKey: "ssh_public_key",
- },
- },
- },
- // case 14
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--required-claim-name", "can_access",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- RequiredClaimName: "can_access",
- },
- },
- },
- // case 15
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--required-claim-value", "yes",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- RequiredClaimValue: "yes",
- },
- },
- },
- // case 16
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--group-claim-name", "groups",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- GroupClaimName: "groups",
- },
- },
- },
- // case 17
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--admin-group", "admin",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- AdminGroup: "admin",
- },
- },
- },
- // case 18
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--restricted-group", "restricted",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- RestrictedGroup: "restricted",
- },
- },
- },
- // case 19
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--group-team-map", `{"org_a_team_1": {"organization-a": ["Team 1"]}, "org_a_all_teams": {"organization-a": ["Team 1", "Team 2", "Team 3"]}}`,
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- GroupTeamMap: `{"org_a_team_1": {"organization-a": ["Team 1"]}, "org_a_all_teams": {"organization-a": ["Team 1", "Team 2", "Team 3"]}}`,
- },
- },
- },
- // case 20
- {
- args: []string{
- "oauth-test",
- "--id", "1",
- "--group-team-map-removal",
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- GroupTeamMapRemoval: true,
- },
- },
- },
- // case 21
- {
- args: []string{
- "oauth-test",
- "--id", "23",
- "--group-team-map-removal=false",
- },
- id: 23,
- existingAuthSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- GroupTeamMapRemoval: true,
- },
- },
- authSource: &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{
- CustomURLMapping: &oauth2.CustomURLMapping{},
- GroupTeamMapRemoval: false,
- },
- },
- },
- // case 22
- {
- args: []string{
- "oauth-test",
- },
- errMsg: "--id flag is missing",
- },
- }
-
- for n, c := range cases {
- // Mock functions.
- var updatedAuthSource *auth.Source
- service := &authService{
- initDB: func(context.Context) error {
- return nil
- },
- createAuthSource: func(ctx context.Context, authSource *auth.Source) error {
- assert.FailNow(t, "should not call createAuthSource", "case: %d", n)
- return nil
- },
- updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
- updatedAuthSource = authSource
- return nil
- },
- getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
- if c.id != 0 {
- assert.Equal(t, c.id, id, "case %d: wrong id", n)
- }
- if c.existingAuthSource != nil {
- return c.existingAuthSource, nil
- }
- return &auth.Source{
- Type: auth.OAuth2,
- Cfg: &oauth2.Source{},
- }, nil
- },
- }
-
- // Create a copy of command to test
- app := cli.Command{}
- app.Flags = microcmdAuthUpdateOauth().Flags
- app.Action = service.updateOauth
-
- // Run it
- err := app.Run(t.Context(), c.args)
- if c.errMsg != "" {
- assert.EqualError(t, err, c.errMsg, "case %d: error should match", n)
- } else {
- require.NoError(t, err, "case %d: should have no errors", n)
- assert.Equal(t, c.authSource, updatedAuthSource, "case %d: wrong authSource", n)
- }
- }
-}
diff --git a/cmd/manager_logging.go b/cmd/manager_logging.go
index c18bfa919b..c543afe872 100644
--- a/cmd/manager_logging.go
+++ b/cmd/manager_logging.go
@@ -44,11 +44,6 @@ func defaultLoggingFlags() []cli.Flag {
Aliases: []string{"e"},
Usage: "Matching expression for the logger",
},
- &cli.StringFlag{
- Name: "exclusion",
- Aliases: []string{"x"},
- Usage: "Exclusion for the logger",
- },
&cli.StringFlag{
Name: "prefix",
Aliases: []string{"p"},
@@ -291,9 +286,6 @@ func commonAddLogger(ctx context.Context, c *cli.Command, mode string, vals map[
if len(c.String("expression")) > 0 {
vals["expression"] = c.String("expression")
}
- if len(c.String("exclusion")) > 0 {
- vals["exclusion"] = c.String("exclusion")
- }
if len(c.String("prefix")) > 0 {
vals["prefix"] = c.String("prefix")
}
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index 71598663b2..1b8d4c6697 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -631,7 +631,6 @@ LEVEL = Info
;LEVEL=
;FLAGS = stdflags or journald
;EXPRESSION =
-;EXCLUSION =
;PREFIX =
;COLORIZE = false
;;
@@ -1768,9 +1767,6 @@ LEVEL = Info
;; Use PASSWD = `your password` for quoting if you use special characters in the password.
;PASSWD =
;;
-;; Alternative location to specify mailer password. You cannot specify both this and PASSWD, and must pick one
-;PASSWD_URI = file:/etc/forgejo/mailer_passwd
-;;
;; Send mails only in plain text, without HTML alternative
;SEND_AS_PLAIN_TEXT = false
;;
@@ -1823,9 +1819,6 @@ LEVEL = Info
;; Password of the receiving account
;PASSWORD =
;;
-;; Alternative location to specify password of the receiving account. You cannot specify both this and PASSWORD, and must pick one
-;PASSWORD_URI = file:/etc/forgejo/email_incoming_password
-;;
;; Whether the IMAP server uses TLS.
;USE_TLS = false
;;
diff --git a/go.mod b/go.mod
index 139095099b..33ad5dbc67 100644
--- a/go.mod
+++ b/go.mod
@@ -2,7 +2,7 @@ module forgejo.org
go 1.24
-toolchain go1.24.5
+toolchain go1.24.4
require (
code.forgejo.org/f3/gof3/v3 v3.11.0
@@ -24,7 +24,7 @@ require (
github.com/ProtonMail/go-crypto v1.3.0
github.com/PuerkitoBio/goquery v1.10.3
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2
- github.com/alecthomas/chroma/v2 v2.19.0
+ github.com/alecthomas/chroma/v2 v2.18.0
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
github.com/blevesearch/bleve/v2 v2.5.2
github.com/buildkite/terminal-to-html/v3 v3.16.8
@@ -42,21 +42,21 @@ require (
github.com/go-ap/activitypub v0.0.0-20231114162308-e219254dc5c9
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73
github.com/go-chi/chi/v5 v5.2.2
- github.com/go-chi/cors v1.2.2
+ github.com/go-chi/cors v1.2.1
github.com/go-co-op/gocron v1.37.0
github.com/go-enry/go-enry/v2 v2.9.2
github.com/go-git/go-git/v5 v5.13.2
github.com/go-ldap/ldap/v3 v3.4.6
github.com/go-openapi/spec v0.21.0
github.com/go-sql-driver/mysql v1.9.3
- github.com/go-webauthn/webauthn v0.13.1
+ github.com/go-webauthn/webauthn v0.13.0
github.com/gobwas/glob v0.2.3
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
github.com/golang-jwt/jwt/v5 v5.2.2
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/google/go-github/v64 v64.0.0
- github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5
+ github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e
github.com/google/uuid v1.6.0
github.com/gorilla/feeds v1.2.0
github.com/gorilla/sessions v1.4.0
@@ -99,13 +99,13 @@ require (
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
gitlab.com/gitlab-org/api/client-go v0.130.1
go.uber.org/mock v0.5.2
- golang.org/x/crypto v0.40.0
+ golang.org/x/crypto v0.39.0
golang.org/x/image v0.27.0
- golang.org/x/net v0.42.0
+ golang.org/x/net v0.41.0
golang.org/x/oauth2 v0.30.0
- golang.org/x/sync v0.16.0
- golang.org/x/sys v0.34.0
- golang.org/x/text v0.27.0
+ golang.org/x/sync v0.15.0
+ golang.org/x/sys v0.33.0
+ golang.org/x/text v0.26.0
google.golang.org/protobuf v1.36.4
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/ini.v1 v1.67.0
@@ -170,7 +170,7 @@ require (
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
- github.com/go-webauthn/x v0.1.22 // indirect
+ github.com/go-webauthn/x v0.1.21 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -244,7 +244,7 @@ require (
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
-replace github.com/nektos/act => code.forgejo.org/forgejo/act v1.29.0
+replace github.com/nektos/act => code.forgejo.org/forgejo/act v1.28.0
replace github.com/mholt/archiver/v3 => code.forgejo.org/forgejo/archiver/v3 v3.5.1
diff --git a/go.sum b/go.sum
index 3c906b45c6..45497a1b49 100644
--- a/go.sum
+++ b/go.sum
@@ -4,8 +4,8 @@ code.forgejo.org/f3/gof3/v3 v3.11.0 h1:f/xToKwqTgxG6PYxvewywjDQyCcyHEEJ6sZqUitFs
code.forgejo.org/f3/gof3/v3 v3.11.0/go.mod h1:4FaRUNSQGBiD1M0DuB0yNv+Z2wMtlOeckgygHSSq4KQ=
code.forgejo.org/forgejo-contrib/go-libravatar v0.0.0-20191008002943-06d1c002b251 h1:HTZl3CBk3ABNYtFI6TPLvJgGKFIhKT5CBk0sbOtkDKU=
code.forgejo.org/forgejo-contrib/go-libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:PphB88CPbx601QrWPMZATeorACeVmQlyv3u+uUMbSaM=
-code.forgejo.org/forgejo/act v1.29.0 h1:CPiI0LRPU0f6gUdQj1ZVax0ySc8CfegY4hiRsymdZU0=
-code.forgejo.org/forgejo/act v1.29.0/go.mod h1:RPqtuaI2FkC1SVOaYCRODo5jIfoMTBVgEOOP3Sdiuh4=
+code.forgejo.org/forgejo/act v1.28.0 h1:96njNC7C1YNyjWq5OWvLZMF/nw0PMthzIA8Nwbnn7jo=
+code.forgejo.org/forgejo/act v1.28.0/go.mod h1:dFuiwAmD5vyrzecysHB2kL/GM3wRpoVPl+WdbCTC8Bs=
code.forgejo.org/forgejo/archiver/v3 v3.5.1 h1:UmmbA7D5550uf71SQjarmrn6yKwOGxtEjb3jaYYtmSE=
code.forgejo.org/forgejo/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
code.forgejo.org/forgejo/go-rpmutils v1.0.0 h1:RZGGeKt70p/WaIEL97pyT6uiiEIoN8/aLmS5Z6WmX0M=
@@ -62,8 +62,8 @@ github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2/go.mod h1:JitQWJ8JuV4Y
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
-github.com/alecthomas/chroma/v2 v2.19.0 h1:Im+SLRgT8maArxv81mULDWN8oKxkzboH07CHesxElq4=
-github.com/alecthomas/chroma/v2 v2.19.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk=
+github.com/alecthomas/chroma/v2 v2.18.0 h1:6h53Q4hW83SuF+jcsp7CVhLsMozzvQvO8HBbKQW+gn4=
+github.com/alecthomas/chroma/v2 v2.18.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk=
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
@@ -215,8 +215,8 @@ github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkPro
github.com/go-chi/chi/v5 v5.0.1/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618=
github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
-github.com/go-chi/cors v1.2.2 h1:Jmey33TE+b+rB7fT8MUy1u0I4L+NARQlK6LhzKPSyQE=
-github.com/go-chi/cors v1.2.2/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
+github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
+github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0=
github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY=
github.com/go-enry/go-enry/v2 v2.9.2 h1:giOQAtCgBX08kosrX818DCQJTCNtKwoPBGu0qb6nKTY=
@@ -250,10 +250,10 @@ github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI6
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
-github.com/go-webauthn/webauthn v0.13.1 h1:Q3/GLXsckVJUPE+BGR6ex26yRIiZ/X2ITaMeSkOftuc=
-github.com/go-webauthn/webauthn v0.13.1/go.mod h1:HeaBromTjgMg1sHZOzyjEiqcrk4Og7mxafDTWDepaXI=
-github.com/go-webauthn/x v0.1.22 h1:rHilV/rYXawarI0uA3uZ5nhLb30Ex8RgbVAsOSt/57o=
-github.com/go-webauthn/x v0.1.22/go.mod h1:+iV9BF4OsvLYzETdc0lmQO2webTos10oH6QydSoWxDM=
+github.com/go-webauthn/webauthn v0.13.0 h1:cJIL1/1l+22UekVhipziAaSgESJxokYkowUqAIsWs0Y=
+github.com/go-webauthn/webauthn v0.13.0/go.mod h1:Oy9o2o79dbLKRPZWWgRIOdtBGAhKnDIaBp2PFkICRHs=
+github.com/go-webauthn/x v0.1.21 h1:nFbckQxudvHEJn2uy1VEi713MeSpApoAv9eRqsb9AdQ=
+github.com/go-webauthn/x v0.1.21/go.mod h1:sEYohtg1zL4An1TXIUIQ5csdmoO+WO0R4R2pGKaHYKA=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
@@ -307,8 +307,8 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
-github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5 h1:xhMrHhTJ6zxu3gA4enFM9MLn9AY7613teCdFnlUVbSQ=
-github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5/go.mod h1:5hDyRhoBCxViHszMt12TnOpEI4VVi+U8Gm9iphldiMA=
+github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
+github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
@@ -585,8 +585,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
-golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
-golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
+golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
+golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/image v0.27.0 h1:C8gA4oWU/tKkdCfYT6T2u4faJu3MeNS5O8UPWlPF61w=
@@ -614,8 +614,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
-golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
-golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
+golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
+golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -627,8 +627,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
-golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
-golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
+golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
+golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -654,8 +654,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
-golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
+golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
+golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -665,8 +665,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
-golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg=
-golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
+golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
+golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -677,8 +677,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
-golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
-golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
+golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
+golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
diff --git a/models/actions/run.go b/models/actions/run.go
index 69592120e9..55def805ed 100644
--- a/models/actions/run.go
+++ b/models/actions/run.go
@@ -284,10 +284,16 @@ func GetLatestRun(ctx context.Context, repoID int64) (*ActionRun, error) {
return &run, nil
}
-func GetRunBefore(ctx context.Context, _ *ActionRun) (*ActionRun, error) {
- // TODO return the most recent run related to the run given in argument
- // see https://codeberg.org/forgejo/user-research/issues/63 for context
- return nil, nil
+// GetRunBefore returns the last run that completed a given timestamp (not inclusive).
+func GetRunBefore(ctx context.Context, repoID int64, timestamp timeutil.TimeStamp) (*ActionRun, error) {
+ var run ActionRun
+ has, err := db.GetEngine(ctx).Where("repo_id=? AND stopped IS NOT NULL AND stopped", repoID, timestamp).OrderBy("stopped DESC").Limit(1).Get(&run)
+ if err != nil {
+ return nil, err
+ } else if !has {
+ return nil, fmt.Errorf("run before: %w", util.ErrNotExist)
+ }
+ return &run, nil
}
func GetLatestRunForBranchAndWorkflow(ctx context.Context, repoID int64, branch, workflowFile, event string) (*ActionRun, error) {
diff --git a/models/actions/run_test.go b/models/actions/run_test.go
index c9a552a2b2..11b03022ff 100644
--- a/models/actions/run_test.go
+++ b/models/actions/run_test.go
@@ -5,7 +5,92 @@ package actions
import (
"testing"
+ "time"
+
+ "forgejo.org/models/db"
+ "forgejo.org/models/unittest"
+ "forgejo.org/modules/timeutil"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
func TestGetRunBefore(t *testing.T) {
+ require.NoError(t, unittest.PrepareTestDatabase())
+
+ // this repo is part of the test database requiring loading "repository.yml" in main_test.go
+ var repoID int64 = 1
+
+ workflowID := "test_workflow"
+
+ // third completed run
+ time1, err := time.Parse(time.RFC3339, "2024-07-31T15:47:55+08:00")
+ require.NoError(t, err)
+ timeutil.MockSet(time1)
+ run1 := ActionRun{
+ ID: 1,
+ Index: 1,
+ RepoID: repoID,
+ Stopped: timeutil.TimeStampNow(),
+ WorkflowID: workflowID,
+ }
+
+ // fourth completed run
+ time2, err := time.Parse(time.RFC3339, "2024-08-31T15:47:55+08:00")
+ require.NoError(t, err)
+ timeutil.MockSet(time2)
+ run2 := ActionRun{
+ ID: 2,
+ Index: 2,
+ RepoID: repoID,
+ Stopped: timeutil.TimeStampNow(),
+ WorkflowID: workflowID,
+ }
+
+ // second completed run
+ time3, err := time.Parse(time.RFC3339, "2024-07-31T15:47:54+08:00")
+ require.NoError(t, err)
+ timeutil.MockSet(time3)
+ run3 := ActionRun{
+ ID: 3,
+ Index: 3,
+ RepoID: repoID,
+ Stopped: timeutil.TimeStampNow(),
+ WorkflowID: workflowID,
+ }
+
+ // first completed run
+ time4, err := time.Parse(time.RFC3339, "2024-06-30T15:47:54+08:00")
+ require.NoError(t, err)
+ timeutil.MockSet(time4)
+ run4 := ActionRun{
+ ID: 4,
+ Index: 4,
+ RepoID: repoID,
+ Stopped: timeutil.TimeStampNow(),
+ WorkflowID: workflowID,
+ }
+ require.NoError(t, db.Insert(db.DefaultContext, &run1))
+ runBefore, err := GetRunBefore(db.DefaultContext, repoID, run1.Stopped)
+ // there is no run before run1
+ require.Error(t, err)
+ require.Nil(t, runBefore)
+
+ // now there is only run3 before run1
+ require.NoError(t, db.Insert(db.DefaultContext, &run3))
+ runBefore, err = GetRunBefore(db.DefaultContext, repoID, run1.Stopped)
+ require.NoError(t, err)
+ assert.Equal(t, run3.ID, runBefore.ID)
+
+ // there still is only run3 before run1
+ require.NoError(t, db.Insert(db.DefaultContext, &run2))
+ runBefore, err = GetRunBefore(db.DefaultContext, repoID, run1.Stopped)
+ require.NoError(t, err)
+ assert.Equal(t, run3.ID, runBefore.ID)
+
+ // run4 is further away from run1
+ require.NoError(t, db.Insert(db.DefaultContext, &run4))
+ runBefore, err = GetRunBefore(db.DefaultContext, repoID, run1.Stopped)
+ require.NoError(t, err)
+ assert.Equal(t, run3.ID, runBefore.ID)
}
diff --git a/models/asymkey/main_test.go b/models/asymkey/main_test.go
index aa13a93f0a..316e8f1d54 100644
--- a/models/asymkey/main_test.go
+++ b/models/asymkey/main_test.go
@@ -15,6 +15,8 @@ func TestMain(m *testing.M) {
"gpg_key.yml",
"public_key.yml",
"TestParseCommitWithSSHSignature/public_key.yml",
+ "deploy_key.yml",
+ "gpg_key_import.yml",
"user.yml",
"email_address.yml",
},
diff --git a/models/db/context.go b/models/db/context.go
index 3e035cd733..35526936af 100644
--- a/models/db/context.go
+++ b/models/db/context.go
@@ -141,7 +141,7 @@ func TxContext(parentCtx context.Context) (*Context, Committer, error) {
return nil, nil, err
}
- return newContext(parentCtx, sess, true), sess, nil
+ return newContext(DefaultContext, sess, true), sess, nil
}
// WithTx represents executing database operations on a transaction, if the transaction exist,
diff --git a/models/db/context_test.go b/models/db/context_test.go
index d12d79ebe1..7ab327b7e9 100644
--- a/models/db/context_test.go
+++ b/models/db/context_test.go
@@ -84,16 +84,4 @@ func TestTxContext(t *testing.T) {
return nil
}))
}
-
- t.Run("Reuses parent context", func(t *testing.T) {
- type unique struct{}
-
- ctx := context.WithValue(db.DefaultContext, unique{}, "yes!")
- assert.False(t, db.InTransaction(ctx))
-
- require.NoError(t, db.WithTx(ctx, func(ctx context.Context) error {
- assert.Equal(t, "yes!", ctx.Value(unique{}))
- return nil
- }))
- })
}
diff --git a/models/db/engine.go b/models/db/engine.go
index 76025f7d67..05a119b08d 100755
--- a/models/db/engine.go
+++ b/models/db/engine.go
@@ -15,7 +15,6 @@ import (
"strings"
"time"
- "forgejo.org/modules/container"
"forgejo.org/modules/log"
"forgejo.org/modules/setting"
@@ -439,12 +438,3 @@ func GetMasterEngine(x Engine) (*xorm.Engine, error) {
return engine, nil
}
-
-// GetTableNames returns the table name of all registered models.
-func GetTableNames() container.Set[string] {
- names := make(container.Set[string])
- for _, table := range tables {
- names.Add(x.TableName(table))
- }
- return names
-}
diff --git a/models/db/table_names_test.go b/models/db/table_names_test.go
deleted file mode 100644
index 176ce9905d..0000000000
--- a/models/db/table_names_test.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2025 The Forgejo Authors. All rights reserved.
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-package db
-
-import (
- "slices"
- "testing"
-
- "forgejo.org/modules/test"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestGetTableNames(t *testing.T) {
- t.Run("Simple", func(t *testing.T) {
- defer test.MockVariableValue(&tables, []any{new(GPGKey)})()
-
- assert.Equal(t, []string{"gpg_key"}, GetTableNames().Values())
- })
-
- t.Run("Multiple tables", func(t *testing.T) {
- defer test.MockVariableValue(&tables, []any{new(GPGKey), new(User), new(BlockedUser)})()
-
- tableNames := GetTableNames().Values()
- slices.Sort(tableNames)
-
- assert.Equal(t, []string{"forgejo_blocked_user", "gpg_key", "user"}, tableNames)
- })
-}
-
-type GPGKey struct{}
-
-type User struct{}
-
-type BlockedUser struct{}
-
-func (*BlockedUser) TableName() string {
- return "forgejo_blocked_user"
-}
diff --git a/models/fixtures/TestActivateUserEmail/email_address.yml b/models/fixtures/TestActivateUserEmail/email_address.yml
deleted file mode 100644
index cf41ff8241..0000000000
--- a/models/fixtures/TestActivateUserEmail/email_address.yml
+++ /dev/null
@@ -1,7 +0,0 @@
--
- id: 1001
- uid: 1001
- email: AnotherTestUserWithUpperCaseEmail@otto.splvs.net
- lower_email: anothertestuserwithuppercaseemail@otto.splvs.net
- is_activated: false
- is_primary: true
diff --git a/models/fixtures/TestActivateUserEmail/user.yml b/models/fixtures/TestActivateUserEmail/user.yml
deleted file mode 100644
index 0a68e70a4a..0000000000
--- a/models/fixtures/TestActivateUserEmail/user.yml
+++ /dev/null
@@ -1,12 +0,0 @@
--
- id: 1001
- lower_name: user1001
- name: user1001
- full_name: User That loves Upper Cases
- email: AnotherTestUserWithUpperCaseEmail@otto.splvs.net
- passwd: ZogKvWdyEx:password
- passwd_hash_algo: dummy
- avatar: ''
- avatar_email: anothertestuserwithuppercaseemail@otto.splvs.net
- login_name: user1
- created_unix: 1672578000
diff --git a/models/fixtures/action_variable.yml b/models/fixtures/action_variable.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/action_variable.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/deploy_key.yml b/models/fixtures/deploy_key.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/deploy_key.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/external_login_user.yml b/models/fixtures/external_login_user.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/external_login_user.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/federated_user.yml b/models/fixtures/federated_user.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/federated_user.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/federation_host.yml b/models/fixtures/federation_host.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/federation_host.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/gpg_key_import.yml b/models/fixtures/gpg_key_import.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/gpg_key_import.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/label.yml b/models/fixtures/label.yml
index 84c2a7f418..acfac74968 100644
--- a/models/fixtures/label.yml
+++ b/models/fixtures/label.yml
@@ -3,7 +3,6 @@
repo_id: 1
org_id: 0
name: label1
- description: 'First label'
color: '#abcdef'
exclusive: false
num_issues: 2
@@ -108,26 +107,3 @@
num_issues: 0
num_closed_issues: 0
archived_unix: 0
-
--
- id: 11
- repo_id: 3
- org_id: 0
- name: " /'?&"
- description: "Malicious label ' "
- color: '#000000'
- exclusive: true
- num_issues: 0
- num_closed_issues: 0
- archived_unix: 0
-
--
- id: 12
- repo_id: 3
- org_id: 0
- name: 'archived label<>'
- color: '#000000'
- exclusive: false
- num_issues: 0
- num_closed_issues: 0
- archived_unix: 2991092130
diff --git a/models/fixtures/login_source.yml b/models/fixtures/login_source.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/login_source.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/protected_branch.yml b/models/fixtures/protected_branch.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/protected_branch.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/pull_auto_merge.yml b/models/fixtures/pull_auto_merge.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/pull_auto_merge.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/push_mirror.yml b/models/fixtures/push_mirror.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/push_mirror.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/repo_archiver.yml b/models/fixtures/repo_archiver.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/repo_archiver.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/repo_indexer_status.yml b/models/fixtures/repo_indexer_status.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/repo_indexer_status.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/fixtures/secret.yml b/models/fixtures/secret.yml
new file mode 100644
index 0000000000..ca780a73aa
--- /dev/null
+++ b/models/fixtures/secret.yml
@@ -0,0 +1 @@
+[] # empty
diff --git a/models/forgejo_migrations/main_test.go b/models/forgejo_migrations/main_test.go
index 2246e327f0..031fe8090d 100644
--- a/models/forgejo_migrations/main_test.go
+++ b/models/forgejo_migrations/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"testing"
diff --git a/models/forgejo_migrations/migrate.go b/models/forgejo_migrations/migrate.go
index fcea69d23f..737350b019 100644
--- a/models/forgejo_migrations/migrate.go
+++ b/models/forgejo_migrations/migrate.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"context"
@@ -108,9 +108,7 @@ var migrations = []*Migration{
// v33 -> v34
NewMigration("Add `notify-email` column to `action_run` table", AddNotifyEmailToActionRun),
// v34 -> v35
- NewMigration("Noop because of https://codeberg.org/forgejo/forgejo/issues/8373", NoopAddIndexToActionRunStopped),
- // v35 -> v36
- NewMigration("Fix wiki unit default permission", FixWikiUnitDefaultPermission),
+ NewMigration("Add index to `stopped` column in `action_run` table", AddIndexToActionRunStopped),
}
// GetCurrentDBVersion returns the current Forgejo database version.
diff --git a/models/forgejo_migrations/migrate_test.go b/models/forgejo_migrations/migrate_test.go
index 9d16c9fe1c..20653929a3 100644
--- a/models/forgejo_migrations/migrate_test.go
+++ b/models/forgejo_migrations/migrate_test.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"testing"
diff --git a/models/forgejo_migrations/v13.go b/models/forgejo_migrations/v13.go
index ba4183885e..614f68249d 100644
--- a/models/forgejo_migrations/v13.go
+++ b/models/forgejo_migrations/v13.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v14.go b/models/forgejo_migrations/v14.go
index 65b857d343..53f1ef2223 100644
--- a/models/forgejo_migrations/v14.go
+++ b/models/forgejo_migrations/v14.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"forgejo.org/models/migrations/base"
diff --git a/models/forgejo_migrations/v15.go b/models/forgejo_migrations/v15.go
index a63199ab19..5e5588dd05 100644
--- a/models/forgejo_migrations/v15.go
+++ b/models/forgejo_migrations/v15.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"time"
diff --git a/models/forgejo_migrations/v16.go b/models/forgejo_migrations/v16.go
index a7d4d5d590..f80bfc5268 100644
--- a/models/forgejo_migrations/v16.go
+++ b/models/forgejo_migrations/v16.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v17.go b/models/forgejo_migrations/v17.go
index 8ef6f2c681..d6e2983d00 100644
--- a/models/forgejo_migrations/v17.go
+++ b/models/forgejo_migrations/v17.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v18.go b/models/forgejo_migrations/v18.go
index e39b0cbf10..e6c1493f0e 100644
--- a/models/forgejo_migrations/v18.go
+++ b/models/forgejo_migrations/v18.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v19.go b/models/forgejo_migrations/v19.go
index 43d279dcb0..69b7746eb1 100644
--- a/models/forgejo_migrations/v19.go
+++ b/models/forgejo_migrations/v19.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v1_20/v1.go b/models/forgejo_migrations/v1_20/v1.go
index f0cb125557..72beaf23de 100644
--- a/models/forgejo_migrations/v1_20/v1.go
+++ b/models/forgejo_migrations/v1_20/v1.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_v1_20
+package forgejo_v1_20 //nolint:revive
import (
"forgejo.org/modules/timeutil"
diff --git a/models/forgejo_migrations/v1_20/v2.go b/models/forgejo_migrations/v1_20/v2.go
index 3f79ac3801..39f3b58924 100644
--- a/models/forgejo_migrations/v1_20/v2.go
+++ b/models/forgejo_migrations/v1_20/v2.go
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
-package forgejo_v1_20
+package forgejo_v1_20 //nolint:revive
import (
"xorm.io/xorm"
diff --git a/models/forgejo_migrations/v1_20/v3.go b/models/forgejo_migrations/v1_20/v3.go
index 49530df556..cce227e6eb 100644
--- a/models/forgejo_migrations/v1_20/v3.go
+++ b/models/forgejo_migrations/v1_20/v3.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_v1_20
+package forgejo_v1_20 //nolint:revive
import (
"forgejo.org/modules/timeutil"
diff --git a/models/forgejo_migrations/v1_22/main_test.go b/models/forgejo_migrations/v1_22/main_test.go
index d6a5bdacee..03c4c5272c 100644
--- a/models/forgejo_migrations/v1_22/main_test.go
+++ b/models/forgejo_migrations/v1_22/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"testing"
diff --git a/models/forgejo_migrations/v1_22/v10.go b/models/forgejo_migrations/v1_22/v10.go
index cf45abdd24..819800ae71 100644
--- a/models/forgejo_migrations/v1_22/v10.go
+++ b/models/forgejo_migrations/v1_22/v10.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/forgejo_migrations/v1_22/v11.go b/models/forgejo_migrations/v1_22/v11.go
index f0f92bd04c..17bb592379 100644
--- a/models/forgejo_migrations/v1_22/v11.go
+++ b/models/forgejo_migrations/v1_22/v11.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/forgejo_migrations/v1_22/v12.go b/models/forgejo_migrations/v1_22/v12.go
index 51354bd3c2..6822524705 100644
--- a/models/forgejo_migrations/v1_22/v12.go
+++ b/models/forgejo_migrations/v1_22/v12.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v1_22/v4.go b/models/forgejo_migrations/v1_22/v4.go
index 499d377bb4..f1195f5f66 100644
--- a/models/forgejo_migrations/v1_22/v4.go
+++ b/models/forgejo_migrations/v1_22/v4.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/forgejo_migrations/v1_22/v5.go b/models/forgejo_migrations/v1_22/v5.go
index 1671d3eed2..55f9fe1338 100644
--- a/models/forgejo_migrations/v1_22/v5.go
+++ b/models/forgejo_migrations/v1_22/v5.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors c/o Codeberg e.V.. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/forgejo_migrations/v1_22/v6.go b/models/forgejo_migrations/v1_22/v6.go
index 072f8e6a15..1a4874872c 100644
--- a/models/forgejo_migrations/v1_22/v6.go
+++ b/models/forgejo_migrations/v1_22/v6.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors c/o Codeberg e.V.. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/forgejo_migrations/v1_22/v7.go b/models/forgejo_migrations/v1_22/v7.go
index e7f6eb412b..b42dd1af67 100644
--- a/models/forgejo_migrations/v1_22/v7.go
+++ b/models/forgejo_migrations/v1_22/v7.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/forgejo_migrations/v1_22/v8.go b/models/forgejo_migrations/v1_22/v8.go
index f23b00d2ad..2d3c0c594b 100644
--- a/models/forgejo_migrations/v1_22/v8.go
+++ b/models/forgejo_migrations/v1_22/v8.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"strings"
diff --git a/models/forgejo_migrations/v1_22/v8_test.go b/models/forgejo_migrations/v1_22/v8_test.go
index 5117dd2dfb..baaba7290f 100644
--- a/models/forgejo_migrations/v1_22/v8_test.go
+++ b/models/forgejo_migrations/v1_22/v8_test.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"testing"
diff --git a/models/forgejo_migrations/v1_22/v9.go b/models/forgejo_migrations/v1_22/v9.go
index e3cdea97f2..34c2844c39 100644
--- a/models/forgejo_migrations/v1_22/v9.go
+++ b/models/forgejo_migrations/v1_22/v9.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v20.go b/models/forgejo_migrations/v20.go
index 91c7b8e911..8ca9e91f73 100644
--- a/models/forgejo_migrations/v20.go
+++ b/models/forgejo_migrations/v20.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v21.go b/models/forgejo_migrations/v21.go
index 61d7950c5a..53f141b2ab 100644
--- a/models/forgejo_migrations/v21.go
+++ b/models/forgejo_migrations/v21.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v22.go b/models/forgejo_migrations/v22.go
index 8078591da6..eeb738799c 100644
--- a/models/forgejo_migrations/v22.go
+++ b/models/forgejo_migrations/v22.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v23.go b/models/forgejo_migrations/v23.go
index a79a4f3d6e..20a916a716 100644
--- a/models/forgejo_migrations/v23.go
+++ b/models/forgejo_migrations/v23.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v24.go b/models/forgejo_migrations/v24.go
index 084a57e1ce..ebfb5fc1c4 100644
--- a/models/forgejo_migrations/v24.go
+++ b/models/forgejo_migrations/v24.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v25.go b/models/forgejo_migrations/v25.go
index 56cde499a3..8e3032a40c 100644
--- a/models/forgejo_migrations/v25.go
+++ b/models/forgejo_migrations/v25.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"context"
diff --git a/models/forgejo_migrations/v25_test.go b/models/forgejo_migrations/v25_test.go
index 68e71da012..e7402fd021 100644
--- a/models/forgejo_migrations/v25_test.go
+++ b/models/forgejo_migrations/v25_test.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"testing"
diff --git a/models/forgejo_migrations/v26.go b/models/forgejo_migrations/v26.go
index a0c47799c2..3292d93ffd 100644
--- a/models/forgejo_migrations/v26.go
+++ b/models/forgejo_migrations/v26.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v27.go b/models/forgejo_migrations/v27.go
index 9cfbc64370..2efa3485a8 100644
--- a/models/forgejo_migrations/v27.go
+++ b/models/forgejo_migrations/v27.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"forgejo.org/modules/timeutil"
diff --git a/models/forgejo_migrations/v28.go b/models/forgejo_migrations/v28.go
index 19f0dcd862..cba888d2ec 100644
--- a/models/forgejo_migrations/v28.go
+++ b/models/forgejo_migrations/v28.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v29.go b/models/forgejo_migrations/v29.go
index 92eb05e8b3..d0c2f723ae 100644
--- a/models/forgejo_migrations/v29.go
+++ b/models/forgejo_migrations/v29.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"database/sql"
diff --git a/models/forgejo_migrations/v30.go b/models/forgejo_migrations/v30.go
index 05a1dff898..6c41a55316 100644
--- a/models/forgejo_migrations/v30.go
+++ b/models/forgejo_migrations/v30.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"time"
diff --git a/models/forgejo_migrations/v30_test.go b/models/forgejo_migrations/v30_test.go
index 152fddeb47..f826dab815 100644
--- a/models/forgejo_migrations/v30_test.go
+++ b/models/forgejo_migrations/v30_test.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"testing"
diff --git a/models/forgejo_migrations/v31.go b/models/forgejo_migrations/v31.go
index 23397c7c13..fdcab21b1a 100644
--- a/models/forgejo_migrations/v31.go
+++ b/models/forgejo_migrations/v31.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"xorm.io/xorm"
diff --git a/models/forgejo_migrations/v31_test.go b/models/forgejo_migrations/v31_test.go
index 6d1690aae0..5b4aac2a60 100644
--- a/models/forgejo_migrations/v31_test.go
+++ b/models/forgejo_migrations/v31_test.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"testing"
diff --git a/models/forgejo_migrations/v32.go b/models/forgejo_migrations/v32.go
index 81b22c585c..bed335ab6b 100644
--- a/models/forgejo_migrations/v32.go
+++ b/models/forgejo_migrations/v32.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"encoding/xml"
diff --git a/models/forgejo_migrations/v32_test.go b/models/forgejo_migrations/v32_test.go
index 24cda891bc..cd33de2608 100644
--- a/models/forgejo_migrations/v32_test.go
+++ b/models/forgejo_migrations/v32_test.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"bytes"
diff --git a/models/forgejo_migrations/v33.go b/models/forgejo_migrations/v33.go
index b9ea8efe47..272035fc23 100644
--- a/models/forgejo_migrations/v33.go
+++ b/models/forgejo_migrations/v33.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"fmt"
diff --git a/models/forgejo_migrations/v33_test.go b/models/forgejo_migrations/v33_test.go
index 1d3298da15..664c704bbc 100644
--- a/models/forgejo_migrations/v33_test.go
+++ b/models/forgejo_migrations/v33_test.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
"testing"
diff --git a/models/forgejo_migrations/v34.go b/models/forgejo_migrations/v34.go
index d193d799e7..9e958b934f 100644
--- a/models/forgejo_migrations/v34.go
+++ b/models/forgejo_migrations/v34.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import "xorm.io/xorm"
diff --git a/models/forgejo_migrations/v35.go b/models/forgejo_migrations/v35.go
index 9b389fcc12..0fb3b43e2c 100644
--- a/models/forgejo_migrations/v35.go
+++ b/models/forgejo_migrations/v35.go
@@ -1,13 +1,19 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
-package forgejo_migrations
+package forgejo_migrations //nolint:revive
import (
+ "forgejo.org/modules/timeutil"
+
"xorm.io/xorm"
)
-// see https://codeberg.org/forgejo/forgejo/issues/8373
-func NoopAddIndexToActionRunStopped(x *xorm.Engine) error {
- return nil
+func AddIndexToActionRunStopped(x *xorm.Engine) error {
+ type ActionRun struct {
+ ID int64
+ Stopped timeutil.TimeStamp `xorm:"index"`
+ }
+
+ return x.Sync(&ActionRun{})
}
diff --git a/models/forgejo_migrations/v36.go b/models/forgejo_migrations/v36.go
deleted file mode 100644
index 1a798147cf..0000000000
--- a/models/forgejo_migrations/v36.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2025 The Forgejo Authors. All rights reserved.
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-package forgejo_migrations
-
-import (
- "xorm.io/xorm"
-)
-
-func FixWikiUnitDefaultPermission(x *xorm.Engine) error {
- // Type is Unit's Type
- type Type int
-
- // Enumerate all the unit types
- const (
- TypeInvalid Type = iota // 0 invalid
- TypeCode // 1 code
- TypeIssues // 2 issues
- TypePullRequests // 3 PRs
- TypeReleases // 4 Releases
- TypeWiki // 5 Wiki
- TypeExternalWiki // 6 ExternalWiki
- TypeExternalTracker // 7 ExternalTracker
- TypeProjects // 8 Projects
- TypePackages // 9 Packages
- TypeActions // 10 Actions
- )
-
- // RepoUnitAccessMode specifies the users access mode to a repo unit
- type UnitAccessMode int
-
- const (
- // UnitAccessModeUnset - no unit mode set
- UnitAccessModeUnset UnitAccessMode = iota // 0
- // UnitAccessModeNone no access
- UnitAccessModeNone // 1
- // UnitAccessModeRead read access
- UnitAccessModeRead // 2
- // UnitAccessModeWrite write access
- UnitAccessModeWrite // 3
- )
- _ = UnitAccessModeNone
- _ = UnitAccessModeWrite
-
- type RepoUnit struct {
- DefaultPermissions UnitAccessMode `xorm:"NOT NULL DEFAULT 0"`
- }
- _, err := x.Where("type = ?", TypeWiki).
- Where("default_permissions = ?", UnitAccessModeRead).
- Cols("default_permissions").
- Update(RepoUnit{
- DefaultPermissions: UnitAccessModeUnset,
- })
- return err
-}
diff --git a/models/migrations/test/tests.go b/models/migrations/test/tests.go
index 6be3b3c2fc..c1f0caf19b 100644
--- a/models/migrations/test/tests.go
+++ b/models/migrations/test/tests.go
@@ -95,8 +95,7 @@ func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, fu
t.Logf("initializing fixtures from: %s", fixturesDir)
if err := unittest.InitFixtures(
unittest.FixturesOptions{
- Dir: fixturesDir,
- SkipCleanRegistedModels: true,
+ Dir: fixturesDir,
}, x); err != nil {
t.Errorf("error whilst initializing fixtures from %s: %v", fixturesDir, err)
return x, deferFn
diff --git a/models/migrations/v1_10/v100.go b/models/migrations/v1_10/v100.go
index 1742bea296..5d2fd8e244 100644
--- a/models/migrations/v1_10/v100.go
+++ b/models/migrations/v1_10/v100.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import (
"net/url"
diff --git a/models/migrations/v1_10/v101.go b/models/migrations/v1_10/v101.go
index 6c8dfe2486..f023a2a0e7 100644
--- a/models/migrations/v1_10/v101.go
+++ b/models/migrations/v1_10/v101.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_10/v88.go b/models/migrations/v1_10/v88.go
index eb8e81c19e..7e86ac364f 100644
--- a/models/migrations/v1_10/v88.go
+++ b/models/migrations/v1_10/v88.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import (
"crypto/sha1"
diff --git a/models/migrations/v1_10/v89.go b/models/migrations/v1_10/v89.go
index 0df2a6e17b..d5f27ffdc6 100644
--- a/models/migrations/v1_10/v89.go
+++ b/models/migrations/v1_10/v89.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_10/v90.go b/models/migrations/v1_10/v90.go
index 5521a97e32..295d4b1c1b 100644
--- a/models/migrations/v1_10/v90.go
+++ b/models/migrations/v1_10/v90.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_10/v91.go b/models/migrations/v1_10/v91.go
index 08db6c2742..48cac2de70 100644
--- a/models/migrations/v1_10/v91.go
+++ b/models/migrations/v1_10/v91.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_10/v92.go b/models/migrations/v1_10/v92.go
index b6c04a9234..9080108594 100644
--- a/models/migrations/v1_10/v92.go
+++ b/models/migrations/v1_10/v92.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import (
"xorm.io/builder"
diff --git a/models/migrations/v1_10/v93.go b/models/migrations/v1_10/v93.go
index c131be9a8d..ee59a8db39 100644
--- a/models/migrations/v1_10/v93.go
+++ b/models/migrations/v1_10/v93.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_10/v94.go b/models/migrations/v1_10/v94.go
index 13b7d7b303..c131af162b 100644
--- a/models/migrations/v1_10/v94.go
+++ b/models/migrations/v1_10/v94.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_10/v95.go b/models/migrations/v1_10/v95.go
index 86b52026bf..3b1f67fd9c 100644
--- a/models/migrations/v1_10/v95.go
+++ b/models/migrations/v1_10/v95.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_10/v96.go b/models/migrations/v1_10/v96.go
index bcbd618b49..3bfb770f24 100644
--- a/models/migrations/v1_10/v96.go
+++ b/models/migrations/v1_10/v96.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import (
"path/filepath"
diff --git a/models/migrations/v1_10/v97.go b/models/migrations/v1_10/v97.go
index 5872bb63e5..dee45b32e3 100644
--- a/models/migrations/v1_10/v97.go
+++ b/models/migrations/v1_10/v97.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_10/v98.go b/models/migrations/v1_10/v98.go
index d21c326459..bdd9aed089 100644
--- a/models/migrations/v1_10/v98.go
+++ b/models/migrations/v1_10/v98.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_10/v99.go b/models/migrations/v1_10/v99.go
index addae66be9..7f287b77aa 100644
--- a/models/migrations/v1_10/v99.go
+++ b/models/migrations/v1_10/v99.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_10
+package v1_10 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_11/v102.go b/models/migrations/v1_11/v102.go
index 15f0c83c36..a585d9c423 100644
--- a/models/migrations/v1_11/v102.go
+++ b/models/migrations/v1_11/v102.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_11/v103.go b/models/migrations/v1_11/v103.go
index a515710160..53527dac58 100644
--- a/models/migrations/v1_11/v103.go
+++ b/models/migrations/v1_11/v103.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_11/v104.go b/models/migrations/v1_11/v104.go
index 7461f0cda3..af3578ca4a 100644
--- a/models/migrations/v1_11/v104.go
+++ b/models/migrations/v1_11/v104.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_11/v105.go b/models/migrations/v1_11/v105.go
index d86973a0f6..b91340c30a 100644
--- a/models/migrations/v1_11/v105.go
+++ b/models/migrations/v1_11/v105.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_11/v106.go b/models/migrations/v1_11/v106.go
index edffe18683..ecb11cdd1e 100644
--- a/models/migrations/v1_11/v106.go
+++ b/models/migrations/v1_11/v106.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_11/v107.go b/models/migrations/v1_11/v107.go
index a158e3bb50..f0bfe5862c 100644
--- a/models/migrations/v1_11/v107.go
+++ b/models/migrations/v1_11/v107.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_11/v108.go b/models/migrations/v1_11/v108.go
index 8f14504ceb..a85096234d 100644
--- a/models/migrations/v1_11/v108.go
+++ b/models/migrations/v1_11/v108.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_11/v109.go b/models/migrations/v1_11/v109.go
index f7616aec7b..ea565ccda3 100644
--- a/models/migrations/v1_11/v109.go
+++ b/models/migrations/v1_11/v109.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_11/v110.go b/models/migrations/v1_11/v110.go
index e94a738f67..fce9be847e 100644
--- a/models/migrations/v1_11/v110.go
+++ b/models/migrations/v1_11/v110.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_11/v111.go b/models/migrations/v1_11/v111.go
index 6f531e4858..cc3dc0d545 100644
--- a/models/migrations/v1_11/v111.go
+++ b/models/migrations/v1_11/v111.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_11/v112.go b/models/migrations/v1_11/v112.go
index 22054e6f68..6112ab51a5 100644
--- a/models/migrations/v1_11/v112.go
+++ b/models/migrations/v1_11/v112.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_11/v113.go b/models/migrations/v1_11/v113.go
index a4d54f66fb..dea344a44f 100644
--- a/models/migrations/v1_11/v113.go
+++ b/models/migrations/v1_11/v113.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_11/v114.go b/models/migrations/v1_11/v114.go
index 9467a8a90c..95adcee989 100644
--- a/models/migrations/v1_11/v114.go
+++ b/models/migrations/v1_11/v114.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"net/url"
diff --git a/models/migrations/v1_11/v115.go b/models/migrations/v1_11/v115.go
index 65094df93d..3d4b41017b 100644
--- a/models/migrations/v1_11/v115.go
+++ b/models/migrations/v1_11/v115.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"crypto/md5"
diff --git a/models/migrations/v1_11/v116.go b/models/migrations/v1_11/v116.go
index 729fbad18b..85aa76c1e0 100644
--- a/models/migrations/v1_11/v116.go
+++ b/models/migrations/v1_11/v116.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_11
+package v1_11 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v117.go b/models/migrations/v1_12/v117.go
index 73b58ca34b..8eadcdef2b 100644
--- a/models/migrations/v1_12/v117.go
+++ b/models/migrations/v1_12/v117.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v118.go b/models/migrations/v1_12/v118.go
index e8b4249743..eb022dc5e4 100644
--- a/models/migrations/v1_12/v118.go
+++ b/models/migrations/v1_12/v118.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v119.go b/models/migrations/v1_12/v119.go
index b4bf29a935..60bfe6a57d 100644
--- a/models/migrations/v1_12/v119.go
+++ b/models/migrations/v1_12/v119.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v120.go b/models/migrations/v1_12/v120.go
index 14d515f5a7..3f7ed8d373 100644
--- a/models/migrations/v1_12/v120.go
+++ b/models/migrations/v1_12/v120.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v121.go b/models/migrations/v1_12/v121.go
index a28ae4e1c9..175ec9164d 100644
--- a/models/migrations/v1_12/v121.go
+++ b/models/migrations/v1_12/v121.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_12/v122.go b/models/migrations/v1_12/v122.go
index bc1b175f6a..6e31d863a1 100644
--- a/models/migrations/v1_12/v122.go
+++ b/models/migrations/v1_12/v122.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v123.go b/models/migrations/v1_12/v123.go
index 52b10bb850..b0c3af07a3 100644
--- a/models/migrations/v1_12/v123.go
+++ b/models/migrations/v1_12/v123.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v124.go b/models/migrations/v1_12/v124.go
index 9a93f436d4..d2ba03ffe0 100644
--- a/models/migrations/v1_12/v124.go
+++ b/models/migrations/v1_12/v124.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v125.go b/models/migrations/v1_12/v125.go
index 7f582ecff5..ec4ffaab25 100644
--- a/models/migrations/v1_12/v125.go
+++ b/models/migrations/v1_12/v125.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v126.go b/models/migrations/v1_12/v126.go
index 64fd7f7478..ca9ec3aa3f 100644
--- a/models/migrations/v1_12/v126.go
+++ b/models/migrations/v1_12/v126.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/builder"
diff --git a/models/migrations/v1_12/v127.go b/models/migrations/v1_12/v127.go
index f686fa617c..11a4042973 100644
--- a/models/migrations/v1_12/v127.go
+++ b/models/migrations/v1_12/v127.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v128.go b/models/migrations/v1_12/v128.go
index 8fca974616..6d7307f470 100644
--- a/models/migrations/v1_12/v128.go
+++ b/models/migrations/v1_12/v128.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v129.go b/models/migrations/v1_12/v129.go
index 3e4d3aca68..cf228242b9 100644
--- a/models/migrations/v1_12/v129.go
+++ b/models/migrations/v1_12/v129.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v130.go b/models/migrations/v1_12/v130.go
index 383ef47492..bfa856796a 100644
--- a/models/migrations/v1_12/v130.go
+++ b/models/migrations/v1_12/v130.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"forgejo.org/modules/json"
diff --git a/models/migrations/v1_12/v131.go b/models/migrations/v1_12/v131.go
index 1266c2f185..5184bc3590 100644
--- a/models/migrations/v1_12/v131.go
+++ b/models/migrations/v1_12/v131.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v132.go b/models/migrations/v1_12/v132.go
index 8b1ae6db93..3b2b28f7ab 100644
--- a/models/migrations/v1_12/v132.go
+++ b/models/migrations/v1_12/v132.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v133.go b/models/migrations/v1_12/v133.go
index 69e20597d8..c9087fc8c1 100644
--- a/models/migrations/v1_12/v133.go
+++ b/models/migrations/v1_12/v133.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_12/v134.go b/models/migrations/v1_12/v134.go
index 1fabdcae96..bba996fd40 100644
--- a/models/migrations/v1_12/v134.go
+++ b/models/migrations/v1_12/v134.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v135.go b/models/migrations/v1_12/v135.go
index 5df0ad7fc4..8898011df5 100644
--- a/models/migrations/v1_12/v135.go
+++ b/models/migrations/v1_12/v135.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v136.go b/models/migrations/v1_12/v136.go
index 7d246a82be..e2557ae002 100644
--- a/models/migrations/v1_12/v136.go
+++ b/models/migrations/v1_12/v136.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v137.go b/models/migrations/v1_12/v137.go
index 9d38483488..0d86b72010 100644
--- a/models/migrations/v1_12/v137.go
+++ b/models/migrations/v1_12/v137.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_12/v138.go b/models/migrations/v1_12/v138.go
index 4485adeb2d..8c8d353f40 100644
--- a/models/migrations/v1_12/v138.go
+++ b/models/migrations/v1_12/v138.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_12/v139.go b/models/migrations/v1_12/v139.go
index 51e57b984a..cd7963524e 100644
--- a/models/migrations/v1_12/v139.go
+++ b/models/migrations/v1_12/v139.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_12
+package v1_12 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_13/v140.go b/models/migrations/v1_13/v140.go
index 5bb612c098..d74f808e9f 100644
--- a/models/migrations/v1_13/v140.go
+++ b/models/migrations/v1_13/v140.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_13/v141.go b/models/migrations/v1_13/v141.go
index b54bc1727c..ae211e0e44 100644
--- a/models/migrations/v1_13/v141.go
+++ b/models/migrations/v1_13/v141.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_13/v142.go b/models/migrations/v1_13/v142.go
index 8939f6f2f8..7490e0f3b4 100644
--- a/models/migrations/v1_13/v142.go
+++ b/models/migrations/v1_13/v142.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"forgejo.org/modules/log"
diff --git a/models/migrations/v1_13/v143.go b/models/migrations/v1_13/v143.go
index 6a8da8b06d..1f9120e2ba 100644
--- a/models/migrations/v1_13/v143.go
+++ b/models/migrations/v1_13/v143.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"forgejo.org/modules/log"
diff --git a/models/migrations/v1_13/v144.go b/models/migrations/v1_13/v144.go
index f138338514..7e801eab8a 100644
--- a/models/migrations/v1_13/v144.go
+++ b/models/migrations/v1_13/v144.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"forgejo.org/modules/log"
diff --git a/models/migrations/v1_13/v145.go b/models/migrations/v1_13/v145.go
index f7d3895c84..a01f577ed1 100644
--- a/models/migrations/v1_13/v145.go
+++ b/models/migrations/v1_13/v145.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_13/v146.go b/models/migrations/v1_13/v146.go
index e6a476a288..a1b54ee3aa 100644
--- a/models/migrations/v1_13/v146.go
+++ b/models/migrations/v1_13/v146.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_13/v147.go b/models/migrations/v1_13/v147.go
index 831ef5842a..cc57504c74 100644
--- a/models/migrations/v1_13/v147.go
+++ b/models/migrations/v1_13/v147.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_13/v148.go b/models/migrations/v1_13/v148.go
index d276db3d61..7bb8ab700b 100644
--- a/models/migrations/v1_13/v148.go
+++ b/models/migrations/v1_13/v148.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_13/v149.go b/models/migrations/v1_13/v149.go
index c1bfe8b09e..3a0c5909d5 100644
--- a/models/migrations/v1_13/v149.go
+++ b/models/migrations/v1_13/v149.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_13/v150.go b/models/migrations/v1_13/v150.go
index 471a531024..be14fd130c 100644
--- a/models/migrations/v1_13/v150.go
+++ b/models/migrations/v1_13/v150.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_13/v151.go b/models/migrations/v1_13/v151.go
index 691b86062d..ff584fff67 100644
--- a/models/migrations/v1_13/v151.go
+++ b/models/migrations/v1_13/v151.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"context"
diff --git a/models/migrations/v1_13/v152.go b/models/migrations/v1_13/v152.go
index 648e26446f..502c82a40d 100644
--- a/models/migrations/v1_13/v152.go
+++ b/models/migrations/v1_13/v152.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_13/v153.go b/models/migrations/v1_13/v153.go
index e5462fc162..0b2dd3eb62 100644
--- a/models/migrations/v1_13/v153.go
+++ b/models/migrations/v1_13/v153.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_13/v154.go b/models/migrations/v1_13/v154.go
index 89dc7821b2..cf31190781 100644
--- a/models/migrations/v1_13/v154.go
+++ b/models/migrations/v1_13/v154.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_13
+package v1_13 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_14/main_test.go b/models/migrations/v1_14/main_test.go
index 57cf995be1..c01faedc35 100644
--- a/models/migrations/v1_14/main_test.go
+++ b/models/migrations/v1_14/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"testing"
diff --git a/models/migrations/v1_14/v155.go b/models/migrations/v1_14/v155.go
index 505a9ae033..e814f59938 100644
--- a/models/migrations/v1_14/v155.go
+++ b/models/migrations/v1_14/v155.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v156.go b/models/migrations/v1_14/v156.go
index 7bbd9f4c85..b6dc91a054 100644
--- a/models/migrations/v1_14/v156.go
+++ b/models/migrations/v1_14/v156.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v157.go b/models/migrations/v1_14/v157.go
index ba69f71130..7187278d29 100644
--- a/models/migrations/v1_14/v157.go
+++ b/models/migrations/v1_14/v157.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_14/v158.go b/models/migrations/v1_14/v158.go
index 2ab3c8a1f0..3fa27cfecd 100644
--- a/models/migrations/v1_14/v158.go
+++ b/models/migrations/v1_14/v158.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"errors"
diff --git a/models/migrations/v1_14/v159.go b/models/migrations/v1_14/v159.go
index 4e921ea1c6..fdd7e12449 100644
--- a/models/migrations/v1_14/v159.go
+++ b/models/migrations/v1_14/v159.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_14/v160.go b/models/migrations/v1_14/v160.go
index 73f3798954..4dea91b514 100644
--- a/models/migrations/v1_14/v160.go
+++ b/models/migrations/v1_14/v160.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_14/v161.go b/models/migrations/v1_14/v161.go
index 9c850ad0c2..6e904cfab6 100644
--- a/models/migrations/v1_14/v161.go
+++ b/models/migrations/v1_14/v161.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"context"
diff --git a/models/migrations/v1_14/v162.go b/models/migrations/v1_14/v162.go
index ead63f16f4..5d6d7c2e3f 100644
--- a/models/migrations/v1_14/v162.go
+++ b/models/migrations/v1_14/v162.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_14/v163.go b/models/migrations/v1_14/v163.go
index 06ac36cbc7..60fc98c0a4 100644
--- a/models/migrations/v1_14/v163.go
+++ b/models/migrations/v1_14/v163.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_14/v164.go b/models/migrations/v1_14/v164.go
index d2fd9b8464..54f6951427 100644
--- a/models/migrations/v1_14/v164.go
+++ b/models/migrations/v1_14/v164.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v165.go b/models/migrations/v1_14/v165.go
index 90fd2b1e46..9315e44197 100644
--- a/models/migrations/v1_14/v165.go
+++ b/models/migrations/v1_14/v165.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_14/v166.go b/models/migrations/v1_14/v166.go
index 4c106bd7da..e5731582fd 100644
--- a/models/migrations/v1_14/v166.go
+++ b/models/migrations/v1_14/v166.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"crypto/sha256"
diff --git a/models/migrations/v1_14/v167.go b/models/migrations/v1_14/v167.go
index d77bbc401e..9d416f6a32 100644
--- a/models/migrations/v1_14/v167.go
+++ b/models/migrations/v1_14/v167.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v168.go b/models/migrations/v1_14/v168.go
index aa93eec19b..a30a8859f7 100644
--- a/models/migrations/v1_14/v168.go
+++ b/models/migrations/v1_14/v168.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_14/v169.go b/models/migrations/v1_14/v169.go
index 4f9df0d96f..5b81bb58b1 100644
--- a/models/migrations/v1_14/v169.go
+++ b/models/migrations/v1_14/v169.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_14/v170.go b/models/migrations/v1_14/v170.go
index a2ff4623e1..7b6498a3e9 100644
--- a/models/migrations/v1_14/v170.go
+++ b/models/migrations/v1_14/v170.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v171.go b/models/migrations/v1_14/v171.go
index 7b200e960a..51a35a02ad 100644
--- a/models/migrations/v1_14/v171.go
+++ b/models/migrations/v1_14/v171.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v172.go b/models/migrations/v1_14/v172.go
index c410d393f1..d49b70f5ad 100644
--- a/models/migrations/v1_14/v172.go
+++ b/models/migrations/v1_14/v172.go
@@ -1,7 +1,7 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_14/v173.go b/models/migrations/v1_14/v173.go
index 7752fbe966..2d9eee9197 100644
--- a/models/migrations/v1_14/v173.go
+++ b/models/migrations/v1_14/v173.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v174.go b/models/migrations/v1_14/v174.go
index 4049e43070..c839e15db8 100644
--- a/models/migrations/v1_14/v174.go
+++ b/models/migrations/v1_14/v174.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v175.go b/models/migrations/v1_14/v175.go
index 49fa17d046..3cda5772a0 100644
--- a/models/migrations/v1_14/v175.go
+++ b/models/migrations/v1_14/v175.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v176.go b/models/migrations/v1_14/v176.go
index ef5dce9a02..1ed49f75fa 100644
--- a/models/migrations/v1_14/v176.go
+++ b/models/migrations/v1_14/v176.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_14/v176_test.go b/models/migrations/v1_14/v176_test.go
index d56b3e0470..d88ff207e7 100644
--- a/models/migrations/v1_14/v176_test.go
+++ b/models/migrations/v1_14/v176_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"testing"
diff --git a/models/migrations/v1_14/v177.go b/models/migrations/v1_14/v177.go
index 96676bf8d9..6e1838f369 100644
--- a/models/migrations/v1_14/v177.go
+++ b/models/migrations/v1_14/v177.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_14/v177_test.go b/models/migrations/v1_14/v177_test.go
index 0e0a67fd33..bffc6f92e3 100644
--- a/models/migrations/v1_14/v177_test.go
+++ b/models/migrations/v1_14/v177_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_14
+package v1_14 //nolint
import (
"testing"
diff --git a/models/migrations/v1_15/main_test.go b/models/migrations/v1_15/main_test.go
index 4cf6d6f695..6c04d3f5ee 100644
--- a/models/migrations/v1_15/main_test.go
+++ b/models/migrations/v1_15/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"testing"
diff --git a/models/migrations/v1_15/v178.go b/models/migrations/v1_15/v178.go
index ca3a5c262e..6d236eb049 100644
--- a/models/migrations/v1_15/v178.go
+++ b/models/migrations/v1_15/v178.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_15/v179.go b/models/migrations/v1_15/v179.go
index ce514cc4a9..b990583303 100644
--- a/models/migrations/v1_15/v179.go
+++ b/models/migrations/v1_15/v179.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_15/v180.go b/models/migrations/v1_15/v180.go
index 0b68c3ceb7..02fbd57cdb 100644
--- a/models/migrations/v1_15/v180.go
+++ b/models/migrations/v1_15/v180.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"forgejo.org/modules/json"
diff --git a/models/migrations/v1_15/v181.go b/models/migrations/v1_15/v181.go
index fb1d3d7a75..2185ed0213 100644
--- a/models/migrations/v1_15/v181.go
+++ b/models/migrations/v1_15/v181.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"strings"
diff --git a/models/migrations/v1_15/v181_test.go b/models/migrations/v1_15/v181_test.go
index 8196f751e5..4154e0b1e9 100644
--- a/models/migrations/v1_15/v181_test.go
+++ b/models/migrations/v1_15/v181_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"strings"
diff --git a/models/migrations/v1_15/v182.go b/models/migrations/v1_15/v182.go
index f53ff11df9..9ca500c0f9 100644
--- a/models/migrations/v1_15/v182.go
+++ b/models/migrations/v1_15/v182.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_15/v182_test.go b/models/migrations/v1_15/v182_test.go
index 2baf90d06a..6865cafac4 100644
--- a/models/migrations/v1_15/v182_test.go
+++ b/models/migrations/v1_15/v182_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"testing"
diff --git a/models/migrations/v1_15/v183.go b/models/migrations/v1_15/v183.go
index 5684e35699..aaad64c220 100644
--- a/models/migrations/v1_15/v183.go
+++ b/models/migrations/v1_15/v183.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_15/v184.go b/models/migrations/v1_15/v184.go
index fbe0dcd780..41b64d4743 100644
--- a/models/migrations/v1_15/v184.go
+++ b/models/migrations/v1_15/v184.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"context"
diff --git a/models/migrations/v1_15/v185.go b/models/migrations/v1_15/v185.go
index 60af59edca..e5878ec193 100644
--- a/models/migrations/v1_15/v185.go
+++ b/models/migrations/v1_15/v185.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_15/v186.go b/models/migrations/v1_15/v186.go
index 55d3199335..ad75822de5 100644
--- a/models/migrations/v1_15/v186.go
+++ b/models/migrations/v1_15/v186.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_15/v187.go b/models/migrations/v1_15/v187.go
index fabef14779..b573fc52ef 100644
--- a/models/migrations/v1_15/v187.go
+++ b/models/migrations/v1_15/v187.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_15/v188.go b/models/migrations/v1_15/v188.go
index 4494e6ff05..71e45cab0e 100644
--- a/models/migrations/v1_15/v188.go
+++ b/models/migrations/v1_15/v188.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_15
+package v1_15 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_16/main_test.go b/models/migrations/v1_16/main_test.go
index 8c0a043be6..6f891f3e94 100644
--- a/models/migrations/v1_16/main_test.go
+++ b/models/migrations/v1_16/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"testing"
diff --git a/models/migrations/v1_16/v189.go b/models/migrations/v1_16/v189.go
index 19bfcb2423..1ee72d9c39 100644
--- a/models/migrations/v1_16/v189.go
+++ b/models/migrations/v1_16/v189.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"encoding/binary"
diff --git a/models/migrations/v1_16/v189_test.go b/models/migrations/v1_16/v189_test.go
index 9d74462a92..90b721d5f1 100644
--- a/models/migrations/v1_16/v189_test.go
+++ b/models/migrations/v1_16/v189_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"testing"
diff --git a/models/migrations/v1_16/v190.go b/models/migrations/v1_16/v190.go
index 1eb6b6ddb4..5953802849 100644
--- a/models/migrations/v1_16/v190.go
+++ b/models/migrations/v1_16/v190.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_16/v191.go b/models/migrations/v1_16/v191.go
index 427476b70b..567f88d6d1 100644
--- a/models/migrations/v1_16/v191.go
+++ b/models/migrations/v1_16/v191.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_16/v192.go b/models/migrations/v1_16/v192.go
index 31e8c36346..731b9fb43a 100644
--- a/models/migrations/v1_16/v192.go
+++ b/models/migrations/v1_16/v192.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_16/v193.go b/models/migrations/v1_16/v193.go
index a5af2de380..8d3ce7a558 100644
--- a/models/migrations/v1_16/v193.go
+++ b/models/migrations/v1_16/v193.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_16/v193_test.go b/models/migrations/v1_16/v193_test.go
index bf8d8a7dc6..8260acf32d 100644
--- a/models/migrations/v1_16/v193_test.go
+++ b/models/migrations/v1_16/v193_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"testing"
diff --git a/models/migrations/v1_16/v194.go b/models/migrations/v1_16/v194.go
index 2e4ed8340e..6aa13c50cf 100644
--- a/models/migrations/v1_16/v194.go
+++ b/models/migrations/v1_16/v194.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_16/v195.go b/models/migrations/v1_16/v195.go
index 4fd42b7bd2..6d7e94141e 100644
--- a/models/migrations/v1_16/v195.go
+++ b/models/migrations/v1_16/v195.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_16/v195_test.go b/models/migrations/v1_16/v195_test.go
index 1fc7b51f3c..71234a6fb3 100644
--- a/models/migrations/v1_16/v195_test.go
+++ b/models/migrations/v1_16/v195_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"testing"
diff --git a/models/migrations/v1_16/v196.go b/models/migrations/v1_16/v196.go
index 6c9caa100f..7cbafc61e5 100644
--- a/models/migrations/v1_16/v196.go
+++ b/models/migrations/v1_16/v196.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_16/v197.go b/models/migrations/v1_16/v197.go
index 862bdfdcbd..97888b2847 100644
--- a/models/migrations/v1_16/v197.go
+++ b/models/migrations/v1_16/v197.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_16/v198.go b/models/migrations/v1_16/v198.go
index 5d3043eb46..8b3c73addc 100644
--- a/models/migrations/v1_16/v198.go
+++ b/models/migrations/v1_16/v198.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_16/v199.go b/models/migrations/v1_16/v199.go
index 4020352f2b..6adcf890af 100644
--- a/models/migrations/v1_16/v199.go
+++ b/models/migrations/v1_16/v199.go
@@ -1,6 +1,6 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
// We used to use a table `remote_version` to store information for updater, now we use `AppState`, so this migration task is a no-op now.
diff --git a/models/migrations/v1_16/v200.go b/models/migrations/v1_16/v200.go
index de57fad8fe..c08c20e51d 100644
--- a/models/migrations/v1_16/v200.go
+++ b/models/migrations/v1_16/v200.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_16/v201.go b/models/migrations/v1_16/v201.go
index 2c43698b0c..35e0c9f2fb 100644
--- a/models/migrations/v1_16/v201.go
+++ b/models/migrations/v1_16/v201.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_16/v202.go b/models/migrations/v1_16/v202.go
index d8c8fdcadc..6ba36152f1 100644
--- a/models/migrations/v1_16/v202.go
+++ b/models/migrations/v1_16/v202.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_16/v203.go b/models/migrations/v1_16/v203.go
index c3241cba57..e8e6b52453 100644
--- a/models/migrations/v1_16/v203.go
+++ b/models/migrations/v1_16/v203.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_16/v204.go b/models/migrations/v1_16/v204.go
index 4d375307e7..ece03e1305 100644
--- a/models/migrations/v1_16/v204.go
+++ b/models/migrations/v1_16/v204.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_16/v205.go b/models/migrations/v1_16/v205.go
index cb452dfd7f..a064b9830d 100644
--- a/models/migrations/v1_16/v205.go
+++ b/models/migrations/v1_16/v205.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_16/v206.go b/models/migrations/v1_16/v206.go
index 01a9c386eb..581a7d76e9 100644
--- a/models/migrations/v1_16/v206.go
+++ b/models/migrations/v1_16/v206.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_16/v207.go b/models/migrations/v1_16/v207.go
index 19126ead1f..91208f066c 100644
--- a/models/migrations/v1_16/v207.go
+++ b/models/migrations/v1_16/v207.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_16/v208.go b/models/migrations/v1_16/v208.go
index fb643324f4..1a11ef096a 100644
--- a/models/migrations/v1_16/v208.go
+++ b/models/migrations/v1_16/v208.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_16/v209.go b/models/migrations/v1_16/v209.go
index 230838647b..be3100e02a 100644
--- a/models/migrations/v1_16/v209.go
+++ b/models/migrations/v1_16/v209.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_16/v210.go b/models/migrations/v1_16/v210.go
index f48ab11db6..375a008e18 100644
--- a/models/migrations/v1_16/v210.go
+++ b/models/migrations/v1_16/v210.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"crypto/ecdh"
diff --git a/models/migrations/v1_16/v210_test.go b/models/migrations/v1_16/v210_test.go
index 8454920aa0..f6423a5821 100644
--- a/models/migrations/v1_16/v210_test.go
+++ b/models/migrations/v1_16/v210_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_16
+package v1_16 //nolint
import (
"encoding/hex"
diff --git a/models/migrations/v1_17/main_test.go b/models/migrations/v1_17/main_test.go
index 166860b3b1..0a8e05ab5f 100644
--- a/models/migrations/v1_17/main_test.go
+++ b/models/migrations/v1_17/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"testing"
diff --git a/models/migrations/v1_17/v211.go b/models/migrations/v1_17/v211.go
index 517cf19388..9b72c8610b 100644
--- a/models/migrations/v1_17/v211.go
+++ b/models/migrations/v1_17/v211.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_17/v212.go b/models/migrations/v1_17/v212.go
index 23868c0bb2..2337adcc80 100644
--- a/models/migrations/v1_17/v212.go
+++ b/models/migrations/v1_17/v212.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_17/v213.go b/models/migrations/v1_17/v213.go
index b2bbdf7279..bb3f466e52 100644
--- a/models/migrations/v1_17/v213.go
+++ b/models/migrations/v1_17/v213.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_17/v214.go b/models/migrations/v1_17/v214.go
index 1925324f0f..2268164919 100644
--- a/models/migrations/v1_17/v214.go
+++ b/models/migrations/v1_17/v214.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_17/v215.go b/models/migrations/v1_17/v215.go
index 431103c98e..5aae798562 100644
--- a/models/migrations/v1_17/v215.go
+++ b/models/migrations/v1_17/v215.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"forgejo.org/models/pull"
diff --git a/models/migrations/v1_17/v216.go b/models/migrations/v1_17/v216.go
index 37aeacb6fc..268f472a42 100644
--- a/models/migrations/v1_17/v216.go
+++ b/models/migrations/v1_17/v216.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
// This migration added non-ideal indices to the action table which on larger datasets slowed things down
// it has been superseded by v218.go
diff --git a/models/migrations/v1_17/v217.go b/models/migrations/v1_17/v217.go
index fef48b7a5b..5f096d4824 100644
--- a/models/migrations/v1_17/v217.go
+++ b/models/migrations/v1_17/v217.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_17/v218.go b/models/migrations/v1_17/v218.go
index 412d124286..5e3dcd0841 100644
--- a/models/migrations/v1_17/v218.go
+++ b/models/migrations/v1_17/v218.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_17/v219.go b/models/migrations/v1_17/v219.go
index 7ca6a26be6..e90656090f 100644
--- a/models/migrations/v1_17/v219.go
+++ b/models/migrations/v1_17/v219.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"time"
diff --git a/models/migrations/v1_17/v220.go b/models/migrations/v1_17/v220.go
index 4e010e5b76..61bbf19725 100644
--- a/models/migrations/v1_17/v220.go
+++ b/models/migrations/v1_17/v220.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
packages_model "forgejo.org/models/packages"
diff --git a/models/migrations/v1_17/v221.go b/models/migrations/v1_17/v221.go
index 3ef34e3f06..84e9a238af 100644
--- a/models/migrations/v1_17/v221.go
+++ b/models/migrations/v1_17/v221.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"encoding/base32"
diff --git a/models/migrations/v1_17/v221_test.go b/models/migrations/v1_17/v221_test.go
index a9c47136b2..02607d6b32 100644
--- a/models/migrations/v1_17/v221_test.go
+++ b/models/migrations/v1_17/v221_test.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"encoding/base32"
diff --git a/models/migrations/v1_17/v222.go b/models/migrations/v1_17/v222.go
index 873769881e..ae910cbcb6 100644
--- a/models/migrations/v1_17/v222.go
+++ b/models/migrations/v1_17/v222.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"context"
diff --git a/models/migrations/v1_17/v223.go b/models/migrations/v1_17/v223.go
index 4f5d34d841..7d92dcf5ae 100644
--- a/models/migrations/v1_17/v223.go
+++ b/models/migrations/v1_17/v223.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_17
+package v1_17 //nolint
import (
"context"
diff --git a/models/migrations/v1_18/main_test.go b/models/migrations/v1_18/main_test.go
index 0c20934cea..33f5c51222 100644
--- a/models/migrations/v1_18/main_test.go
+++ b/models/migrations/v1_18/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"testing"
diff --git a/models/migrations/v1_18/v224.go b/models/migrations/v1_18/v224.go
index 6dc12020ea..f3d522b91a 100644
--- a/models/migrations/v1_18/v224.go
+++ b/models/migrations/v1_18/v224.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_18/v225.go b/models/migrations/v1_18/v225.go
index 266eccfff8..86bcb1323d 100644
--- a/models/migrations/v1_18/v225.go
+++ b/models/migrations/v1_18/v225.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_18/v226.go b/models/migrations/v1_18/v226.go
index 8ed9761476..f87e24b11d 100644
--- a/models/migrations/v1_18/v226.go
+++ b/models/migrations/v1_18/v226.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"xorm.io/builder"
diff --git a/models/migrations/v1_18/v227.go b/models/migrations/v1_18/v227.go
index d39a010159..b6250fb76c 100644
--- a/models/migrations/v1_18/v227.go
+++ b/models/migrations/v1_18/v227.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_18/v228.go b/models/migrations/v1_18/v228.go
index 3f5b69734d..1161c8a4c9 100644
--- a/models/migrations/v1_18/v228.go
+++ b/models/migrations/v1_18/v228.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_18/v229.go b/models/migrations/v1_18/v229.go
index 00d794725f..f96dde9840 100644
--- a/models/migrations/v1_18/v229.go
+++ b/models/migrations/v1_18/v229.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_18/v229_test.go b/models/migrations/v1_18/v229_test.go
index 903a60c851..ac5e726a79 100644
--- a/models/migrations/v1_18/v229_test.go
+++ b/models/migrations/v1_18/v229_test.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"testing"
diff --git a/models/migrations/v1_18/v230.go b/models/migrations/v1_18/v230.go
index 078fce7643..ea5b4d02e1 100644
--- a/models/migrations/v1_18/v230.go
+++ b/models/migrations/v1_18/v230.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_18/v230_test.go b/models/migrations/v1_18/v230_test.go
index da31b0dc9b..7dd6675673 100644
--- a/models/migrations/v1_18/v230_test.go
+++ b/models/migrations/v1_18/v230_test.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_18
+package v1_18 //nolint
import (
"testing"
diff --git a/models/migrations/v1_19/main_test.go b/models/migrations/v1_19/main_test.go
index 9d1c3a57ea..7c56926f4c 100644
--- a/models/migrations/v1_19/main_test.go
+++ b/models/migrations/v1_19/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"testing"
diff --git a/models/migrations/v1_19/v231.go b/models/migrations/v1_19/v231.go
index 8ef1e4e743..79e46132f0 100644
--- a/models/migrations/v1_19/v231.go
+++ b/models/migrations/v1_19/v231.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_19/v232.go b/models/migrations/v1_19/v232.go
index 2aab2cf830..7fb4a5ac8d 100644
--- a/models/migrations/v1_19/v232.go
+++ b/models/migrations/v1_19/v232.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_19/v233.go b/models/migrations/v1_19/v233.go
index e62e8a9356..191afd4868 100644
--- a/models/migrations/v1_19/v233.go
+++ b/models/migrations/v1_19/v233.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_19/v233_test.go b/models/migrations/v1_19/v233_test.go
index 3d5eac9887..4dc35d1e27 100644
--- a/models/migrations/v1_19/v233_test.go
+++ b/models/migrations/v1_19/v233_test.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"testing"
diff --git a/models/migrations/v1_19/v234.go b/models/migrations/v1_19/v234.go
index e00b1cc2b6..c610a423dd 100644
--- a/models/migrations/v1_19/v234.go
+++ b/models/migrations/v1_19/v234.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_19/v235.go b/models/migrations/v1_19/v235.go
index 297d90f65a..3715de3920 100644
--- a/models/migrations/v1_19/v235.go
+++ b/models/migrations/v1_19/v235.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_19/v236.go b/models/migrations/v1_19/v236.go
index c453f95e04..fa01a6ab80 100644
--- a/models/migrations/v1_19/v236.go
+++ b/models/migrations/v1_19/v236.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_19/v237.go b/models/migrations/v1_19/v237.go
index cf30226ccd..b23c765aa5 100644
--- a/models/migrations/v1_19/v237.go
+++ b/models/migrations/v1_19/v237.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_19/v238.go b/models/migrations/v1_19/v238.go
index b257315319..7c912a8341 100644
--- a/models/migrations/v1_19/v238.go
+++ b/models/migrations/v1_19/v238.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_19/v239.go b/models/migrations/v1_19/v239.go
index 8f4a65be95..10076f2401 100644
--- a/models/migrations/v1_19/v239.go
+++ b/models/migrations/v1_19/v239.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_19/v240.go b/models/migrations/v1_19/v240.go
index c49ce2f49a..4ca5becede 100644
--- a/models/migrations/v1_19/v240.go
+++ b/models/migrations/v1_19/v240.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"forgejo.org/models/db"
diff --git a/models/migrations/v1_19/v241.go b/models/migrations/v1_19/v241.go
index e35801a057..a617d6fd2f 100644
--- a/models/migrations/v1_19/v241.go
+++ b/models/migrations/v1_19/v241.go
@@ -1,7 +1,7 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_19/v242.go b/models/migrations/v1_19/v242.go
index 87ca9cf214..bbf227ef77 100644
--- a/models/migrations/v1_19/v242.go
+++ b/models/migrations/v1_19/v242.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_19/v243.go b/models/migrations/v1_19/v243.go
index 9c3f372594..55bbfafb2f 100644
--- a/models/migrations/v1_19/v243.go
+++ b/models/migrations/v1_19/v243.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_19
+package v1_19 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_20/main_test.go b/models/migrations/v1_20/main_test.go
index ee5eec5ef6..f870dca429 100644
--- a/models/migrations/v1_20/main_test.go
+++ b/models/migrations/v1_20/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"testing"
diff --git a/models/migrations/v1_20/v244.go b/models/migrations/v1_20/v244.go
index 76cdccaca5..977566ad7d 100644
--- a/models/migrations/v1_20/v244.go
+++ b/models/migrations/v1_20/v244.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_20/v245.go b/models/migrations/v1_20/v245.go
index 5e034568c4..7e6585388b 100644
--- a/models/migrations/v1_20/v245.go
+++ b/models/migrations/v1_20/v245.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"context"
diff --git a/models/migrations/v1_20/v246.go b/models/migrations/v1_20/v246.go
index 22bf723404..e6340ef079 100644
--- a/models/migrations/v1_20/v246.go
+++ b/models/migrations/v1_20/v246.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_20/v247.go b/models/migrations/v1_20/v247.go
index 056699d744..9ed810a623 100644
--- a/models/migrations/v1_20/v247.go
+++ b/models/migrations/v1_20/v247.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"forgejo.org/modules/log"
diff --git a/models/migrations/v1_20/v248.go b/models/migrations/v1_20/v248.go
index 4f2091e4bc..40555210e7 100644
--- a/models/migrations/v1_20/v248.go
+++ b/models/migrations/v1_20/v248.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_20/v249.go b/models/migrations/v1_20/v249.go
index 0aebb2a343..d2b096bf58 100644
--- a/models/migrations/v1_20/v249.go
+++ b/models/migrations/v1_20/v249.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_20/v250.go b/models/migrations/v1_20/v250.go
index e12223691f..cfcde2fc9b 100644
--- a/models/migrations/v1_20/v250.go
+++ b/models/migrations/v1_20/v250.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"strings"
diff --git a/models/migrations/v1_20/v251.go b/models/migrations/v1_20/v251.go
index 7d2d259df6..c8665ba7eb 100644
--- a/models/migrations/v1_20/v251.go
+++ b/models/migrations/v1_20/v251.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"forgejo.org/modules/log"
diff --git a/models/migrations/v1_20/v252.go b/models/migrations/v1_20/v252.go
index 435cce7ebe..bb85c78309 100644
--- a/models/migrations/v1_20/v252.go
+++ b/models/migrations/v1_20/v252.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"forgejo.org/modules/log"
diff --git a/models/migrations/v1_20/v253.go b/models/migrations/v1_20/v253.go
index 73354fd485..5f4057e9d9 100644
--- a/models/migrations/v1_20/v253.go
+++ b/models/migrations/v1_20/v253.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"forgejo.org/modules/log"
diff --git a/models/migrations/v1_20/v254.go b/models/migrations/v1_20/v254.go
index 9cdbfb3916..1e26979a5b 100644
--- a/models/migrations/v1_20/v254.go
+++ b/models/migrations/v1_20/v254.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_20/v255.go b/models/migrations/v1_20/v255.go
index baa3c4b6d8..49b0ecf220 100644
--- a/models/migrations/v1_20/v255.go
+++ b/models/migrations/v1_20/v255.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_20/v256.go b/models/migrations/v1_20/v256.go
index 7b84c1e154..822153b93e 100644
--- a/models/migrations/v1_20/v256.go
+++ b/models/migrations/v1_20/v256.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_20/v257.go b/models/migrations/v1_20/v257.go
index 8045909dba..70f229d73f 100644
--- a/models/migrations/v1_20/v257.go
+++ b/models/migrations/v1_20/v257.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_20/v258.go b/models/migrations/v1_20/v258.go
index 1d3faffdae..47174ce805 100644
--- a/models/migrations/v1_20/v258.go
+++ b/models/migrations/v1_20/v258.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_20/v259.go b/models/migrations/v1_20/v259.go
index 9b2b68263e..f10b94fa9c 100644
--- a/models/migrations/v1_20/v259.go
+++ b/models/migrations/v1_20/v259.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_20/v259_test.go b/models/migrations/v1_20/v259_test.go
index b41b6c7995..32e4aa3050 100644
--- a/models/migrations/v1_20/v259_test.go
+++ b/models/migrations/v1_20/v259_test.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_20
+package v1_20 //nolint
import (
"sort"
diff --git a/models/migrations/v1_21/main_test.go b/models/migrations/v1_21/main_test.go
index 3f10a39a94..7104887afb 100644
--- a/models/migrations/v1_21/main_test.go
+++ b/models/migrations/v1_21/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"testing"
diff --git a/models/migrations/v1_21/v260.go b/models/migrations/v1_21/v260.go
index b73b53bd61..245f3011ab 100644
--- a/models/migrations/v1_21/v260.go
+++ b/models/migrations/v1_21/v260.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_21/v261.go b/models/migrations/v1_21/v261.go
index 83a4927704..743bef152d 100644
--- a/models/migrations/v1_21/v261.go
+++ b/models/migrations/v1_21/v261.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_21/v262.go b/models/migrations/v1_21/v262.go
index 6e88e29b9d..23e900572a 100644
--- a/models/migrations/v1_21/v262.go
+++ b/models/migrations/v1_21/v262.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v263.go b/models/migrations/v1_21/v263.go
index 55c418bde0..2c7cbadf0d 100644
--- a/models/migrations/v1_21/v263.go
+++ b/models/migrations/v1_21/v263.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_21/v264.go b/models/migrations/v1_21/v264.go
index acd2c9bb48..5615600072 100644
--- a/models/migrations/v1_21/v264.go
+++ b/models/migrations/v1_21/v264.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"context"
diff --git a/models/migrations/v1_21/v265.go b/models/migrations/v1_21/v265.go
index b6892acc27..800eb95f72 100644
--- a/models/migrations/v1_21/v265.go
+++ b/models/migrations/v1_21/v265.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v266.go b/models/migrations/v1_21/v266.go
index 440549e868..79a5f5e14c 100644
--- a/models/migrations/v1_21/v266.go
+++ b/models/migrations/v1_21/v266.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v267.go b/models/migrations/v1_21/v267.go
index 13992d8776..f94696a22b 100644
--- a/models/migrations/v1_21/v267.go
+++ b/models/migrations/v1_21/v267.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_21/v268.go b/models/migrations/v1_21/v268.go
index b677d2383e..332793ff07 100644
--- a/models/migrations/v1_21/v268.go
+++ b/models/migrations/v1_21/v268.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v269.go b/models/migrations/v1_21/v269.go
index 042040927d..475ec02380 100644
--- a/models/migrations/v1_21/v269.go
+++ b/models/migrations/v1_21/v269.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v270.go b/models/migrations/v1_21/v270.go
index ab7c5660ba..b9cc84d3ac 100644
--- a/models/migrations/v1_21/v270.go
+++ b/models/migrations/v1_21/v270.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v271.go b/models/migrations/v1_21/v271.go
index e3ce2d4b74..f45c113c1f 100644
--- a/models/migrations/v1_21/v271.go
+++ b/models/migrations/v1_21/v271.go
@@ -1,8 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
-
+package v1_21 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_21/v272.go b/models/migrations/v1_21/v272.go
index 14c1e0c4b0..a729c49f1b 100644
--- a/models/migrations/v1_21/v272.go
+++ b/models/migrations/v1_21/v272.go
@@ -1,8 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
-
+package v1_21 //nolint
import (
"xorm.io/xorm"
)
diff --git a/models/migrations/v1_21/v273.go b/models/migrations/v1_21/v273.go
index d6ec80d3d5..1ec6ade566 100644
--- a/models/migrations/v1_21/v273.go
+++ b/models/migrations/v1_21/v273.go
@@ -1,8 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
-
+package v1_21 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_21/v274.go b/models/migrations/v1_21/v274.go
index a1211d1fdd..b74e5fed51 100644
--- a/models/migrations/v1_21/v274.go
+++ b/models/migrations/v1_21/v274.go
@@ -1,8 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
-
+package v1_21 //nolint
import (
"time"
diff --git a/models/migrations/v1_21/v275.go b/models/migrations/v1_21/v275.go
index 2bfe5c72fa..78804a59d6 100644
--- a/models/migrations/v1_21/v275.go
+++ b/models/migrations/v1_21/v275.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v276.go b/models/migrations/v1_21/v276.go
index 3b0bc23da7..0830c3bd92 100644
--- a/models/migrations/v1_21/v276.go
+++ b/models/migrations/v1_21/v276.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
repo_model "forgejo.org/models/repo"
diff --git a/models/migrations/v1_21/v277.go b/models/migrations/v1_21/v277.go
index 0c102eddde..12529160b7 100644
--- a/models/migrations/v1_21/v277.go
+++ b/models/migrations/v1_21/v277.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v278.go b/models/migrations/v1_21/v278.go
index 846f228678..d6a462d1e7 100644
--- a/models/migrations/v1_21/v278.go
+++ b/models/migrations/v1_21/v278.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_21/v279.go b/models/migrations/v1_21/v279.go
index beb39effe1..2abd1bbe84 100644
--- a/models/migrations/v1_21/v279.go
+++ b/models/migrations/v1_21/v279.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_21
+package v1_21 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_22/main_test.go b/models/migrations/v1_22/main_test.go
index 7b05993e09..dc991b78fe 100644
--- a/models/migrations/v1_22/main_test.go
+++ b/models/migrations/v1_22/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"testing"
diff --git a/models/migrations/v1_22/v280.go b/models/migrations/v1_22/v280.go
index 2271cb6089..a8ee4a3bf7 100644
--- a/models/migrations/v1_22/v280.go
+++ b/models/migrations/v1_22/v280.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_22/v281.go b/models/migrations/v1_22/v281.go
index 2eeca9be82..5271c786be 100644
--- a/models/migrations/v1_22/v281.go
+++ b/models/migrations/v1_22/v281.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_22/v282.go b/models/migrations/v1_22/v282.go
index eed64c30f7..baad9e0916 100644
--- a/models/migrations/v1_22/v282.go
+++ b/models/migrations/v1_22/v282.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_22/v283.go b/models/migrations/v1_22/v283.go
index 33a2513069..86946d1c39 100644
--- a/models/migrations/v1_22/v283.go
+++ b/models/migrations/v1_22/v283.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_22/v283_test.go b/models/migrations/v1_22/v283_test.go
index 652d96ac16..d8e147a131 100644
--- a/models/migrations/v1_22/v283_test.go
+++ b/models/migrations/v1_22/v283_test.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"testing"
diff --git a/models/migrations/v1_22/v284.go b/models/migrations/v1_22/v284.go
index 31b38f6aed..2b95078980 100644
--- a/models/migrations/v1_22/v284.go
+++ b/models/migrations/v1_22/v284.go
@@ -1,8 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
-
+package v1_22 //nolint
import (
"xorm.io/xorm"
)
diff --git a/models/migrations/v1_22/v285.go b/models/migrations/v1_22/v285.go
index fed89f670e..a55cc17c04 100644
--- a/models/migrations/v1_22/v285.go
+++ b/models/migrations/v1_22/v285.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"time"
diff --git a/models/migrations/v1_22/v286.go b/models/migrations/v1_22/v286.go
index 05247bb436..d0489e7aeb 100644
--- a/models/migrations/v1_22/v286.go
+++ b/models/migrations/v1_22/v286.go
@@ -1,6 +1,6 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_22/v286_test.go b/models/migrations/v1_22/v286_test.go
index 5bb3334df2..c63deef495 100644
--- a/models/migrations/v1_22/v286_test.go
+++ b/models/migrations/v1_22/v286_test.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"testing"
diff --git a/models/migrations/v1_22/v287.go b/models/migrations/v1_22/v287.go
index 5fd901f9de..c8b1593286 100644
--- a/models/migrations/v1_22/v287.go
+++ b/models/migrations/v1_22/v287.go
@@ -1,7 +1,7 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_22/v288.go b/models/migrations/v1_22/v288.go
index 78be3b6ef2..44e4991851 100644
--- a/models/migrations/v1_22/v288.go
+++ b/models/migrations/v1_22/v288.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_22/v289.go b/models/migrations/v1_22/v289.go
index 78689a4ffa..b9941aadd9 100644
--- a/models/migrations/v1_22/v289.go
+++ b/models/migrations/v1_22/v289.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_22/v290.go b/models/migrations/v1_22/v290.go
index ebafab6567..594e417644 100644
--- a/models/migrations/v1_22/v290.go
+++ b/models/migrations/v1_22/v290.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_22/v290_test.go b/models/migrations/v1_22/v290_test.go
index a1907cf4d6..569d77bc16 100644
--- a/models/migrations/v1_22/v290_test.go
+++ b/models/migrations/v1_22/v290_test.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Forgejo Authors c/o Codeberg e.V.. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"strconv"
diff --git a/models/migrations/v1_22/v291.go b/models/migrations/v1_22/v291.go
index 823a644a95..74726fae96 100644
--- a/models/migrations/v1_22/v291.go
+++ b/models/migrations/v1_22/v291.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_22/v292.go b/models/migrations/v1_22/v292.go
index 440f48ce80..beca556aee 100644
--- a/models/migrations/v1_22/v292.go
+++ b/models/migrations/v1_22/v292.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
// NOTE: noop the original migration has bug which some projects will be skip, so
// these projects will have no default board.
diff --git a/models/migrations/v1_22/v293.go b/models/migrations/v1_22/v293.go
index e9c9746b26..9f38c3db56 100644
--- a/models/migrations/v1_22/v293.go
+++ b/models/migrations/v1_22/v293.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_22/v293_test.go b/models/migrations/v1_22/v293_test.go
index 6b1931b761..444146737d 100644
--- a/models/migrations/v1_22/v293_test.go
+++ b/models/migrations/v1_22/v293_test.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"testing"
diff --git a/models/migrations/v1_22/v294.go b/models/migrations/v1_22/v294.go
index 6c52372306..314b4519f1 100644
--- a/models/migrations/v1_22/v294.go
+++ b/models/migrations/v1_22/v294.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_22/v294_test.go b/models/migrations/v1_22/v294_test.go
index e87a4bc85f..ef7b67ca5b 100644
--- a/models/migrations/v1_22/v294_test.go
+++ b/models/migrations/v1_22/v294_test.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import (
"slices"
@@ -45,8 +45,7 @@ func Test_AddUniqueIndexForProjectIssue(t *testing.T) {
for _, index := range tables[0].Indexes {
if index.Type == schemas.UniqueType {
found = true
- slices.Sort(index.Cols)
- assert.Equal(t, []string{"issue_id", "project_id"}, index.Cols)
+ slices.Equal(index.Cols, []string{"project_id", "issue_id"})
break
}
}
diff --git a/models/migrations/v1_22/v295.go b/models/migrations/v1_22/v295.go
index 319b1a399b..17bdadb4ad 100644
--- a/models/migrations/v1_22/v295.go
+++ b/models/migrations/v1_22/v295.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_22/v296.go b/models/migrations/v1_22/v296.go
index 75350f9f65..1ecacab95f 100644
--- a/models/migrations/v1_22/v296.go
+++ b/models/migrations/v1_22/v296.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_22/v298.go b/models/migrations/v1_22/v298.go
index 7700173a00..b9f3b95ade 100644
--- a/models/migrations/v1_22/v298.go
+++ b/models/migrations/v1_22/v298.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_22
+package v1_22 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_23/main_test.go b/models/migrations/v1_23/main_test.go
index 5fb4fec999..0fd90a4a67 100644
--- a/models/migrations/v1_23/main_test.go
+++ b/models/migrations/v1_23/main_test.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_23
+package v1_23 //nolint
import (
"testing"
diff --git a/models/migrations/v1_23/v299.go b/models/migrations/v1_23/v299.go
index 73ce19c875..f6db960c3b 100644
--- a/models/migrations/v1_23/v299.go
+++ b/models/migrations/v1_23/v299.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_23
+package v1_23 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_23/v300.go b/models/migrations/v1_23/v300.go
index 404d8dbea8..f1f1cccdbf 100644
--- a/models/migrations/v1_23/v300.go
+++ b/models/migrations/v1_23/v300.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_23
+package v1_23 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_23/v301.go b/models/migrations/v1_23/v301.go
index f2a4d8c559..b7797f6c6b 100644
--- a/models/migrations/v1_23/v301.go
+++ b/models/migrations/v1_23/v301.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_23
+package v1_23 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_23/v302.go b/models/migrations/v1_23/v302.go
index 1b056993bd..c8ed786d63 100644
--- a/models/migrations/v1_23/v302.go
+++ b/models/migrations/v1_23/v302.go
@@ -1,7 +1,7 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_23
+package v1_23 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_23/v303.go b/models/migrations/v1_23/v303.go
index 03197d2857..fae0131bdd 100644
--- a/models/migrations/v1_23/v303.go
+++ b/models/migrations/v1_23/v303.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors.
// SPDX-License-Identifier: GPL-3.0-or-later
-package v1_23
+package v1_23 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_23/v303_test.go b/models/migrations/v1_23/v303_test.go
index f2c764bae3..f105d11830 100644
--- a/models/migrations/v1_23/v303_test.go
+++ b/models/migrations/v1_23/v303_test.go
@@ -1,7 +1,7 @@
// Copyright 2025 The Forgejo Authors.
// SPDX-License-Identifier: GPL-3.0-or-later
-package v1_23
+package v1_23 //nolint
import (
"testing"
diff --git a/models/migrations/v1_6/v70.go b/models/migrations/v1_6/v70.go
index eb669f57b6..ec6bd09bb5 100644
--- a/models/migrations/v1_6/v70.go
+++ b/models/migrations/v1_6/v70.go
@@ -1,7 +1,7 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_6
+package v1_6 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_6/v71.go b/models/migrations/v1_6/v71.go
index 42fe8cd1ba..3706ad4406 100644
--- a/models/migrations/v1_6/v71.go
+++ b/models/migrations/v1_6/v71.go
@@ -1,7 +1,7 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_6
+package v1_6 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_6/v72.go b/models/migrations/v1_6/v72.go
index 7cd2331376..4df2a0f6e9 100644
--- a/models/migrations/v1_6/v72.go
+++ b/models/migrations/v1_6/v72.go
@@ -1,7 +1,7 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_6
+package v1_6 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_7/v73.go b/models/migrations/v1_7/v73.go
index e0b7a28537..b5a748aae3 100644
--- a/models/migrations/v1_7/v73.go
+++ b/models/migrations/v1_7/v73.go
@@ -1,7 +1,7 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_7
+package v1_7 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_7/v74.go b/models/migrations/v1_7/v74.go
index 376be37a24..f0567e3c9b 100644
--- a/models/migrations/v1_7/v74.go
+++ b/models/migrations/v1_7/v74.go
@@ -1,7 +1,7 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_7
+package v1_7 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_7/v75.go b/models/migrations/v1_7/v75.go
index ef11575466..fa7430970c 100644
--- a/models/migrations/v1_7/v75.go
+++ b/models/migrations/v1_7/v75.go
@@ -1,7 +1,7 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_7
+package v1_7 //nolint
import (
"xorm.io/builder"
diff --git a/models/migrations/v1_8/v76.go b/models/migrations/v1_8/v76.go
index 8d47280b41..61ad006a47 100644
--- a/models/migrations/v1_8/v76.go
+++ b/models/migrations/v1_8/v76.go
@@ -1,7 +1,7 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_8
+package v1_8 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_8/v77.go b/models/migrations/v1_8/v77.go
index 4fe5ebe635..8b19993924 100644
--- a/models/migrations/v1_8/v77.go
+++ b/models/migrations/v1_8/v77.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_8
+package v1_8 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_8/v78.go b/models/migrations/v1_8/v78.go
index 840fc20d96..8102b19335 100644
--- a/models/migrations/v1_8/v78.go
+++ b/models/migrations/v1_8/v78.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_8
+package v1_8 //nolint
import (
"forgejo.org/models/migrations/base"
diff --git a/models/migrations/v1_8/v79.go b/models/migrations/v1_8/v79.go
index c8e0db531f..f7d2d68f96 100644
--- a/models/migrations/v1_8/v79.go
+++ b/models/migrations/v1_8/v79.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_8
+package v1_8 //nolint
import (
"forgejo.org/modules/setting"
diff --git a/models/migrations/v1_8/v80.go b/models/migrations/v1_8/v80.go
index 6f9df47a93..cebbbead28 100644
--- a/models/migrations/v1_8/v80.go
+++ b/models/migrations/v1_8/v80.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_8
+package v1_8 //nolint
import "xorm.io/xorm"
diff --git a/models/migrations/v1_8/v81.go b/models/migrations/v1_8/v81.go
index 8152a47ad7..734fc24641 100644
--- a/models/migrations/v1_8/v81.go
+++ b/models/migrations/v1_8/v81.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_8
+package v1_8 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_9/v82.go b/models/migrations/v1_9/v82.go
index 235c73c504..78a90bdde9 100644
--- a/models/migrations/v1_9/v82.go
+++ b/models/migrations/v1_9/v82.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_9
+package v1_9 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_9/v83.go b/models/migrations/v1_9/v83.go
index 9640564a44..fa24a92d28 100644
--- a/models/migrations/v1_9/v83.go
+++ b/models/migrations/v1_9/v83.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_9
+package v1_9 //nolint
import (
"forgejo.org/modules/timeutil"
diff --git a/models/migrations/v1_9/v84.go b/models/migrations/v1_9/v84.go
index 423915ae57..c7155fe9cf 100644
--- a/models/migrations/v1_9/v84.go
+++ b/models/migrations/v1_9/v84.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_9
+package v1_9 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_9/v85.go b/models/migrations/v1_9/v85.go
index 9d5adc82dd..d8e9d91840 100644
--- a/models/migrations/v1_9/v85.go
+++ b/models/migrations/v1_9/v85.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_9
+package v1_9 //nolint
import (
"fmt"
diff --git a/models/migrations/v1_9/v86.go b/models/migrations/v1_9/v86.go
index 9464ff0cf6..cf2725d158 100644
--- a/models/migrations/v1_9/v86.go
+++ b/models/migrations/v1_9/v86.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_9
+package v1_9 //nolint
import (
"xorm.io/xorm"
diff --git a/models/migrations/v1_9/v87.go b/models/migrations/v1_9/v87.go
index 81a4ebf80d..fa01b6e5e3 100644
--- a/models/migrations/v1_9/v87.go
+++ b/models/migrations/v1_9/v87.go
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
-package v1_9
+package v1_9 //nolint
import (
"xorm.io/xorm"
diff --git a/models/packages/package.go b/models/packages/package.go
index c06dcf5eb3..bdd1c74cad 100644
--- a/models/packages/package.go
+++ b/models/packages/package.go
@@ -125,7 +125,7 @@ func (pt Type) Name() string {
case TypeRpm:
return "RPM"
case TypeAlt:
- return "ALT"
+ return "Alt"
case TypeRubyGems:
return "RubyGems"
case TypeSwift:
diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go
index e50f79e945..c11ad70627 100644
--- a/models/repo/repo_unit.go
+++ b/models/repo/repo_unit.go
@@ -41,30 +41,27 @@ func (err ErrUnitTypeNotExist) Unwrap() error {
}
// RepoUnitAccessMode specifies the users access mode to a repo unit
-// Only UnitAccessModeWrite is used by the wiki, to mark it as instance-writable
type UnitAccessMode int
const (
// UnitAccessModeUnset - no unit mode set
UnitAccessModeUnset UnitAccessMode = iota // 0
-
// UnitAccessModeNone no access
- // UnitAccessModeNone UnitAccessMode = 1
+ UnitAccessModeNone // 1
// UnitAccessModeRead read access
- // UnitAccessModeRead UnitAccessMode = 2
-
+ UnitAccessModeRead // 2
// UnitAccessModeWrite write access
- UnitAccessModeWrite UnitAccessMode = 3
+ UnitAccessModeWrite // 3
)
func (mode UnitAccessMode) ToAccessMode(modeIfUnset perm.AccessMode) perm.AccessMode {
switch mode {
case UnitAccessModeUnset:
return modeIfUnset
- // case UnitAccessModeNone:
- // return perm.AccessModeNone
- // case UnitAccessModeRead:
- // return perm.AccessModeRead
+ case UnitAccessModeNone:
+ return perm.AccessModeNone
+ case UnitAccessModeRead:
+ return perm.AccessModeRead
case UnitAccessModeWrite:
return perm.AccessModeWrite
default:
diff --git a/models/repo/repo_unit_test.go b/models/repo/repo_unit_test.go
index 3d6d408fcb..a1964519bd 100644
--- a/models/repo/repo_unit_test.go
+++ b/models/repo/repo_unit_test.go
@@ -34,8 +34,8 @@ func TestActionsConfig(t *testing.T) {
}
func TestRepoUnitAccessMode(t *testing.T) {
- // assert.Equal(t, perm.AccessModeNone, UnitAccessModeNone.ToAccessMode(perm.AccessModeAdmin))
- // assert.Equal(t, perm.AccessModeRead, UnitAccessModeRead.ToAccessMode(perm.AccessModeAdmin))
+ assert.Equal(t, perm.AccessModeNone, UnitAccessModeNone.ToAccessMode(perm.AccessModeAdmin))
+ assert.Equal(t, perm.AccessModeRead, UnitAccessModeRead.ToAccessMode(perm.AccessModeAdmin))
assert.Equal(t, perm.AccessModeWrite, UnitAccessModeWrite.ToAccessMode(perm.AccessModeAdmin))
assert.Equal(t, perm.AccessModeRead, UnitAccessModeUnset.ToAccessMode(perm.AccessModeRead))
}
diff --git a/models/unittest/fixture_loader.go b/models/unittest/fixture_loader.go
index dda5c48d35..67ef1b28df 100644
--- a/models/unittest/fixture_loader.go
+++ b/models/unittest/fixture_loader.go
@@ -12,8 +12,6 @@ import (
"path/filepath"
"strings"
- "forgejo.org/modules/container"
-
"gopkg.in/yaml.v3"
)
@@ -34,15 +32,13 @@ type loader struct {
fixtureFiles []*fixtureFile
}
-func newFixtureLoader(db *sql.DB, dialect string, fixturePaths []string, allTableNames container.Set[string]) (*loader, error) {
+func newFixtureLoader(db *sql.DB, dialect string, fixturePaths []string) (*loader, error) {
l := &loader{
db: db,
dialect: dialect,
fixtureFiles: []*fixtureFile{},
}
- tablesWithoutFixture := allTableNames
-
// Load fixtures
for _, fixturePath := range fixturePaths {
stat, err := os.Stat(fixturePath)
@@ -64,7 +60,6 @@ func newFixtureLoader(db *sql.DB, dialect string, fixturePaths []string, allTabl
return nil, err
}
l.fixtureFiles = append(l.fixtureFiles, fixtureFile)
- tablesWithoutFixture.Remove(fixtureFile.name)
}
}
} else {
@@ -76,14 +71,6 @@ func newFixtureLoader(db *sql.DB, dialect string, fixturePaths []string, allTabl
}
}
- // Even though these tables have no fixtures, they can still be used and ensure
- // they are cleaned.
- for table := range tablesWithoutFixture.Seq() {
- l.fixtureFiles = append(l.fixtureFiles, &fixtureFile{
- name: table,
- })
- }
-
return l, nil
}
@@ -191,13 +178,13 @@ func (l *loader) Load() error {
}()
// Clean the table and re-insert the fixtures.
- tableDeleted := make(container.Set[string])
+ tableDeleted := map[string]struct{}{}
for _, fixture := range l.fixtureFiles {
- if !tableDeleted.Contains(fixture.name) {
+ if _, ok := tableDeleted[fixture.name]; !ok {
if _, err := tx.Exec(fmt.Sprintf("DELETE FROM %s", l.quoteKeyword(fixture.name))); err != nil {
return fmt.Errorf("cannot delete table %s: %w", fixture.name, err)
}
- tableDeleted.Add(fixture.name)
+ tableDeleted[fixture.name] = struct{}{}
}
for _, insertSQL := range fixture.insertSQLs {
diff --git a/models/unittest/fixtures.go b/models/unittest/fixtures.go
index 829cc16466..6dc5c8412d 100644
--- a/models/unittest/fixtures.go
+++ b/models/unittest/fixtures.go
@@ -7,12 +7,10 @@ package unittest
import (
"fmt"
"path/filepath"
- "sync"
"time"
"forgejo.org/models/db"
"forgejo.org/modules/auth/password/hash"
- "forgejo.org/modules/container"
"forgejo.org/modules/setting"
"xorm.io/xorm"
@@ -46,8 +44,6 @@ func OverrideFixtures(dir string) func() {
}
}
-var allTableNames = sync.OnceValue(db.GetTableNames)
-
// InitFixtures initialize test fixtures for a test database
func InitFixtures(opts FixturesOptions, engine ...*xorm.Engine) (err error) {
e, err := GetXORMEngine(engine...)
@@ -79,12 +75,7 @@ func InitFixtures(opts FixturesOptions, engine ...*xorm.Engine) (err error) {
panic("Unsupported RDBMS for test")
}
- var allTables container.Set[string]
- if !opts.SkipCleanRegistedModels {
- allTables = allTableNames().Clone()
- }
-
- fixturesLoader, err = newFixtureLoader(e.DB().DB, dialect, fixturePaths, allTables)
+ fixturesLoader, err = newFixtureLoader(e.DB().DB, dialect, fixturePaths)
if err != nil {
return err
}
diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go
index 29ec82c55f..d34c9e9a0a 100644
--- a/models/unittest/testdb.go
+++ b/models/unittest/testdb.go
@@ -217,10 +217,6 @@ type FixturesOptions struct {
Files []string
Dirs []string
Base string
- // By default all registered models are cleaned, even if they do not have
- // fixture. Enabling this will skip that and only models with fixtures are
- // considered.
- SkipCleanRegistedModels bool
}
// CreateTestEngine creates a memory database and loads the fixture data from fixturesDir
diff --git a/models/user/activitypub.go b/models/user/activitypub.go
index aabf2336fc..816fd8a098 100644
--- a/models/user/activitypub.go
+++ b/models/user/activitypub.go
@@ -19,7 +19,7 @@ func (u *User) APActorID() string {
return fmt.Sprintf("%sapi/v1/activitypub/user-id/%s", setting.AppURL, url.PathEscape(fmt.Sprintf("%d", u.ID)))
}
-// KeyID returns the ID of the user's public key
-func (u *User) KeyID() string {
+// APActorKeyID returns the ID of the user's public key
+func (u *User) APActorKeyID() string {
return u.APActorID() + "#main-key"
}
diff --git a/models/user/email_address_test.go b/models/user/email_address_test.go
index 85f5b16c65..1801f57a23 100644
--- a/models/user/email_address_test.go
+++ b/models/user/email_address_test.go
@@ -181,20 +181,3 @@ func TestDeletePrimaryEmailAddressOfUser(t *testing.T) {
assert.True(t, user_model.IsErrEmailAddressNotExist(err))
assert.Nil(t, email)
}
-
-func TestActivateUserEmail(t *testing.T) {
- defer unittest.OverrideFixtures("models/fixtures/TestActivateUserEmail")()
- require.NoError(t, unittest.PrepareTestDatabase())
-
- t.Run("Activate email", func(t *testing.T) {
- require.NoError(t, user_model.ActivateUserEmail(t.Context(), 1001, "AnotherTestUserWithUpperCaseEmail@otto.splvs.net", true))
-
- unittest.AssertExistsAndLoadBean(t, &user_model.EmailAddress{UID: 1001}, "is_activated = true")
- })
-
- t.Run("Deactivate email", func(t *testing.T) {
- require.NoError(t, user_model.ActivateUserEmail(t.Context(), 1001, "AnotherTestUserWithUpperCaseEmail@otto.splvs.net", false))
-
- unittest.AssertExistsAndLoadBean(t, &user_model.EmailAddress{UID: 1001}, "is_activated = false")
- })
-}
diff --git a/models/user/user.go b/models/user/user.go
index b124572bb6..eedd1db80e 100644
--- a/models/user/user.go
+++ b/models/user/user.go
@@ -182,11 +182,11 @@ func (u *User) BeforeUpdate() {
u.MaxRepoCreation = -1
}
- // Ensure AvatarEmail is set for non-organization users, because organization
- // are not required to have a email set.
+ // Organization does not need email
+ u.Email = strings.ToLower(u.Email)
if !u.IsOrganization() {
if len(u.AvatarEmail) == 0 {
- u.AvatarEmail = strings.ToLower(u.Email)
+ u.AvatarEmail = u.Email
}
}
diff --git a/models/user/user_repository.go b/models/user/user_repository.go
index 85f44f1598..3f24efb1fb 100644
--- a/models/user/user_repository.go
+++ b/models/user/user_repository.go
@@ -57,6 +57,14 @@ func CreateFederatedUser(ctx context.Context, user *User, federatedUser *Federat
return committer.Commit()
}
+func (federatedUser *FederatedUser) UpdateFederatedUser(ctx context.Context) error {
+ if _, err := validation.IsValid(federatedUser); err != nil {
+ return err
+ }
+ _, err := db.GetEngine(ctx).ID(federatedUser.ID).Cols("inbox_path").Update(federatedUser)
+ return err
+}
+
func FindFederatedUser(ctx context.Context, externalID string, federationHostID int64) (*User, *FederatedUser, error) {
federatedUser := new(FederatedUser)
user := new(User)
@@ -211,6 +219,7 @@ func RemoveFollower(ctx context.Context, followedUser *User, followingUser *Fede
return err
}
+// TODO: We should unify Activity-pub-following and classical following (see models/user/follow.go)
func IsFollowingAp(ctx context.Context, followedUser *User, followingUser *FederatedUser) (bool, error) {
if res, err := validation.IsValid(followedUser); !res {
return false, err
diff --git a/models/user/user_test.go b/models/user/user_test.go
index f9a3aa6075..fd9d05653f 100644
--- a/models/user/user_test.go
+++ b/models/user/user_test.go
@@ -150,7 +150,7 @@ func TestAPActorID_APActorID(t *testing.T) {
func TestKeyID(t *testing.T) {
user := user_model.User{ID: 1}
- url := user.KeyID()
+ url := user.APActorKeyID()
expected := "https://try.gitea.io/api/v1/activitypub/user-id/1#main-key"
assert.Equal(t, expected, url)
}
diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go
index fb6fa8b543..d015fb7bec 100644
--- a/modules/activitypub/client.go
+++ b/modules/activitypub/client.go
@@ -89,7 +89,6 @@ func NewClientFactory() (c *ClientFactory, err error) {
type APClientFactory interface {
WithKeys(ctx context.Context, user *user_model.User, pubID string) (APClient, error)
- WithKeysDirect(ctx context.Context, privateKey, pubID string) (APClient, error)
}
// Client struct
@@ -104,8 +103,12 @@ type Client struct {
}
// NewRequest function
-func (cf *ClientFactory) WithKeysDirect(ctx context.Context, privateKey, pubID string) (APClient, error) {
- privPem, _ := pem.Decode([]byte(privateKey))
+func (cf *ClientFactory) WithKeys(ctx context.Context, user *user_model.User, pubID string) (APClient, error) {
+ priv, err := GetPrivateKey(ctx, user)
+ if err != nil {
+ return nil, err
+ }
+ privPem, _ := pem.Decode([]byte(priv))
privParsed, err := x509.ParsePKCS1PrivateKey(privPem.Bytes)
if err != nil {
return nil, err
@@ -123,14 +126,6 @@ func (cf *ClientFactory) WithKeysDirect(ctx context.Context, privateKey, pubID s
return &c, nil
}
-func (cf *ClientFactory) WithKeys(ctx context.Context, user *user_model.User, pubID string) (APClient, error) {
- priv, err := GetPrivateKey(ctx, user)
- if err != nil {
- return nil, err
- }
- return cf.WithKeysDirect(ctx, priv, pubID)
-}
-
// NewRequest function
func (c *Client) newRequest(method string, b []byte, to string) (req *http.Request, err error) {
buf := bytes.NewBuffer(b)
@@ -154,14 +149,12 @@ func (c *Client) Post(b []byte, to string) (resp *http.Response, err error) {
return nil, err
}
- if c.pubID != "" {
- signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.postHeaders, httpsig.Signature, httpsigExpirationTime)
- if err != nil {
- return nil, err
- }
- if err := signer.SignRequest(c.priv, c.pubID, req, b); err != nil {
- return nil, err
- }
+ signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.postHeaders, httpsig.Signature, httpsigExpirationTime)
+ if err != nil {
+ return nil, err
+ }
+ if err := signer.SignRequest(c.priv, c.pubID, req, b); err != nil {
+ return nil, err
}
resp, err = c.client.Do(req)
@@ -174,15 +167,12 @@ func (c *Client) Get(to string) (resp *http.Response, err error) {
if req, err = c.newRequest(http.MethodGet, nil, to); err != nil {
return nil, err
}
-
- if c.pubID != "" {
- signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.getHeaders, httpsig.Signature, httpsigExpirationTime)
- if err != nil {
- return nil, err
- }
- if err := signer.SignRequest(c.priv, c.pubID, req, nil); err != nil {
- return nil, err
- }
+ signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.getHeaders, httpsig.Signature, httpsigExpirationTime)
+ if err != nil {
+ return nil, err
+ }
+ if err := signer.SignRequest(c.priv, c.pubID, req, nil); err != nil {
+ return nil, err
}
resp, err = c.client.Do(req)
diff --git a/modules/container/set.go b/modules/container/set.go
index d3719dc552..70f837bc66 100644
--- a/modules/container/set.go
+++ b/modules/container/set.go
@@ -74,8 +74,3 @@ func (s Set[T]) Values() []T {
func (s Set[T]) Seq() iter.Seq[T] {
return maps.Keys(s)
}
-
-// Clone returns a identical shallow copy of this set.
-func (s Set[T]) Clone() Set[T] {
- return maps.Clone(s)
-}
diff --git a/modules/container/set_test.go b/modules/container/set_test.go
index 44e4847f6b..af5e9126ab 100644
--- a/modules/container/set_test.go
+++ b/modules/container/set_test.go
@@ -47,11 +47,4 @@ func TestSet(t *testing.T) {
assert.False(t, s.IsSubset([]string{"key1"}))
assert.True(t, s.IsSubset([]string{}))
-
- t.Run("Clone", func(t *testing.T) {
- clonedSet := s.Clone()
- clonedSet.Remove("key6")
- assert.False(t, clonedSet.Contains("key6"))
- assert.True(t, s.Contains("key6"))
- })
}
diff --git a/modules/git/blob.go b/modules/git/blob.go
index 4eef5f0e2a..14ca2b1445 100644
--- a/modules/git/blob.go
+++ b/modules/git/blob.go
@@ -220,7 +220,7 @@ func (b *Blob) GuessContentType() (typesniffer.SniffedType, error) {
}
defer r.Close()
- return typesniffer.DetectContentTypeFromReader(r, b.Name())
+ return typesniffer.DetectContentTypeFromReader(r)
}
// GetBlob finds the blob object in the repository.
diff --git a/modules/git/pushoptions/pushoptions.go b/modules/git/pushoptions/pushoptions.go
index e96ba0a339..9709a8be79 100644
--- a/modules/git/pushoptions/pushoptions.go
+++ b/modules/git/pushoptions/pushoptions.go
@@ -4,7 +4,6 @@
package pushoptions
import (
- "encoding/base64"
"fmt"
"os"
"strconv"
@@ -110,22 +109,5 @@ func (o gitPushOptions) GetBool(key Key, def bool) bool {
func (o gitPushOptions) GetString(key Key) (string, bool) {
val, ok := o[string(key)]
- if !ok {
- return "", false
- }
-
- // If the value is prefixed with `{base64}` then everything after that is very
- // likely to be encoded via base64.
- base64Value, found := strings.CutPrefix(val, "{base64}")
- if !found {
- return val, true
- }
-
- value, err := base64.StdEncoding.DecodeString(base64Value)
- if err != nil {
- // Not valid base64? Return the original value.
- return val, true
- }
-
- return string(value), true
+ return val, ok
}
diff --git a/modules/git/pushoptions/pushoptions_test.go b/modules/git/pushoptions/pushoptions_test.go
index d7c50649d0..1cb36d9d1e 100644
--- a/modules/git/pushoptions/pushoptions_test.go
+++ b/modules/git/pushoptions/pushoptions_test.go
@@ -4,7 +4,6 @@
package pushoptions
import (
- "encoding/base64"
"fmt"
"testing"
@@ -93,23 +92,6 @@ func TestParse(t *testing.T) {
assert.False(t, options.Parse("unknown=value"))
assert.True(t, options.Empty())
})
-
- t.Run("Base64 values", func(t *testing.T) {
- options := New()
-
- description := `I contain
-a
-line`
- assert.True(t, options.Parse(fmt.Sprintf("%s={base64}%s", AgitDescription, base64.StdEncoding.EncodeToString([]byte(description)))))
- val, ok := options.GetString(AgitDescription)
- assert.True(t, ok)
- assert.Equal(t, description, val)
-
- assert.True(t, options.Parse(fmt.Sprintf("%s={base64}fooled you", AgitTitle)))
- val, ok = options.GetString(AgitTitle)
- assert.True(t, ok)
- assert.Equal(t, "{base64}fooled you", val)
- })
}
func TestReadEnv(t *testing.T) {
diff --git a/modules/git/repo_blame.go b/modules/git/repo_blame.go
index d812354af5..139cdd7be9 100644
--- a/modules/git/repo_blame.go
+++ b/modules/git/repo_blame.go
@@ -4,46 +4,20 @@
package git
import (
- "errors"
"fmt"
- "regexp"
-)
-
-var (
- ErrBlameFileDoesNotExist = errors.New("the blamed file does not exist")
- ErrBlameFileNotEnoughLines = errors.New("the blamed file has not enough lines")
-
- notEnoughLinesRe = regexp.MustCompile(`^fatal: file .+ has only \d+ lines?\n$`)
)
// LineBlame returns the latest commit at the given line
-func (repo *Repository) LineBlame(revision, file string, line uint64) (*Commit, error) {
- res, _, gitErr := NewCommand(repo.Ctx, "blame").
+func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Commit, error) {
+ res, _, err := NewCommand(repo.Ctx, "blame").
AddOptionFormat("-L %d,%d", line, line).
AddOptionValues("-p", revision).
- AddDashesAndList(file).RunStdString(&RunOpts{Dir: repo.Path})
- if gitErr != nil {
- stdErr := gitErr.Stderr()
-
- if stdErr == fmt.Sprintf("fatal: no such path %s in %s\n", file, revision) {
- return nil, ErrBlameFileDoesNotExist
- }
- if notEnoughLinesRe.MatchString(stdErr) {
- return nil, ErrBlameFileNotEnoughLines
- }
-
- return nil, gitErr
- }
-
- objectFormat, err := repo.GetObjectFormat()
+ AddDashesAndList(file).RunStdString(&RunOpts{Dir: path})
if err != nil {
return nil, err
}
-
- objectIDLen := objectFormat.FullLength()
- if len(res) < objectIDLen {
- return nil, fmt.Errorf("output of blame is invalid, cannot contain commit ID: %s", res)
+ if len(res) < 40 {
+ return nil, fmt.Errorf("invalid result of blame: %s", res)
}
-
- return repo.GetCommit(res[:objectIDLen])
+ return repo.GetCommit(res[:40])
}
diff --git a/modules/git/repo_blame_test.go b/modules/git/repo_blame_test.go
deleted file mode 100644
index 126b95386d..0000000000
--- a/modules/git/repo_blame_test.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2025 The Forgejo Authors. All rights reserved.
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-package git
-
-import (
- "path/filepath"
- "testing"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func TestLineBlame(t *testing.T) {
- t.Run("SHA1", func(t *testing.T) {
- repo, err := OpenRepository(t.Context(), filepath.Join(testReposDir, "repo1_bare"))
- require.NoError(t, err)
- defer repo.Close()
-
- commit, err := repo.LineBlame("HEAD", "foo/link_short", 1)
- require.NoError(t, err)
- assert.Equal(t, "37991dec2c8e592043f47155ce4808d4580f9123", commit.ID.String())
-
- commit, err = repo.LineBlame("HEAD", "foo/link_short", 512)
- require.ErrorIs(t, err, ErrBlameFileNotEnoughLines)
- assert.Nil(t, commit)
-
- commit, err = repo.LineBlame("HEAD", "non-existent/path", 512)
- require.ErrorIs(t, err, ErrBlameFileDoesNotExist)
- assert.Nil(t, commit)
- })
-
- t.Run("SHA256", func(t *testing.T) {
- skipIfSHA256NotSupported(t)
-
- repo, err := OpenRepository(t.Context(), filepath.Join(testReposDir, "repo1_bare_sha256"))
- require.NoError(t, err)
- defer repo.Close()
-
- commit, err := repo.LineBlame("HEAD", "foo/link_short", 1)
- require.NoError(t, err)
- assert.Equal(t, "6aae864a3d1d0d6a5be0cc64028c1e7021e2632b031fd8eb82afc5a283d1c3d1", commit.ID.String())
-
- commit, err = repo.LineBlame("HEAD", "foo/link_short", 512)
- require.ErrorIs(t, err, ErrBlameFileNotEnoughLines)
- assert.Nil(t, commit)
-
- commit, err = repo.LineBlame("HEAD", "non-existent/path", 512)
- require.ErrorIs(t, err, ErrBlameFileDoesNotExist)
- assert.Nil(t, commit)
- })
-}
diff --git a/modules/git/repo_branch.go b/modules/git/repo_branch.go
index 1e38bf2946..3a9aa3e4e6 100644
--- a/modules/git/repo_branch.go
+++ b/modules/git/repo_branch.go
@@ -19,9 +19,15 @@ import (
// BranchPrefix base dir of the branch information file store on git
const BranchPrefix = "refs/heads/"
+// IsReferenceExist returns true if given reference exists in the repository.
+func IsReferenceExist(ctx context.Context, repoPath, name string) bool {
+ _, _, err := NewCommand(ctx, "show-ref", "--verify").AddDashesAndList(name).RunStdString(&RunOpts{Dir: repoPath})
+ return err == nil
+}
+
// IsBranchExist returns true if given branch exists in the repository.
func IsBranchExist(ctx context.Context, repoPath, name string) bool {
- return NewCommand(ctx, "show-ref", "--verify", "--quiet").AddDashesAndList(BranchPrefix+name).Run(&RunOpts{Dir: repoPath}) == nil
+ return IsReferenceExist(ctx, repoPath, BranchPrefix+name)
}
// Branch represents a Git branch.
diff --git a/modules/git/repo_branch_test.go b/modules/git/repo_branch_test.go
index e61ea6f5d7..1e0fea7cd4 100644
--- a/modules/git/repo_branch_test.go
+++ b/modules/git/repo_branch_test.go
@@ -1,5 +1,4 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
-// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package git
@@ -196,17 +195,3 @@ func TestRepository_IsReferenceExist(t *testing.T) {
})
}
}
-
-func TestIsBranchExist(t *testing.T) {
- repo1Path := filepath.Join(testReposDir, "repo1_bare")
-
- assert.True(t, IsBranchExist(t.Context(), repo1Path, "branch1"))
- assert.True(t, IsBranchExist(t.Context(), repo1Path, "branch2"))
- assert.True(t, IsBranchExist(t.Context(), repo1Path, "master"))
-
- assert.False(t, IsBranchExist(t.Context(), repo1Path, "HEAD"))
- assert.False(t, IsBranchExist(t.Context(), repo1Path, "153f451b9ee7fa1da317ab17a127e9fd9d384310"))
- assert.False(t, IsBranchExist(t.Context(), repo1Path, "153f451b9ee7fa1da317ab17a127e9fd9d384310"))
- assert.False(t, IsBranchExist(t.Context(), repo1Path, "signed-tag"))
- assert.False(t, IsBranchExist(t.Context(), repo1Path, "test"))
-}
diff --git a/modules/httplib/serve.go b/modules/httplib/serve.go
index d385ac21c9..c5f0658d4e 100644
--- a/modules/httplib/serve.go
+++ b/modules/httplib/serve.go
@@ -99,7 +99,7 @@ func setServeHeadersByFile(r *http.Request, w http.ResponseWriter, filePath stri
Filename: path.Base(filePath),
}
- sniffedType := typesniffer.DetectContentType(mineBuf, opts.Filename)
+ sniffedType := typesniffer.DetectContentType(mineBuf)
// the "render" parameter came from year 2016: 638dd24c, it doesn't have clear meaning, so I think it could be removed later
isPlain := sniffedType.IsText() || r.FormValue("render") != ""
diff --git a/modules/indexer/code/bleve/bleve.go b/modules/indexer/code/bleve/bleve.go
index 4c8b5f2a86..c53b7a2e6d 100644
--- a/modules/indexer/code/bleve/bleve.go
+++ b/modules/indexer/code/bleve/bleve.go
@@ -177,7 +177,7 @@ func (b *Indexer) addUpdate(ctx context.Context, batchWriter git.WriteCloserErro
fileContents, err := io.ReadAll(io.LimitReader(batchReader, size))
if err != nil {
return err
- } else if !typesniffer.DetectContentType(fileContents, update.Filename).IsText() {
+ } else if !typesniffer.DetectContentType(fileContents).IsText() {
// FIXME: UTF-16 files will probably fail here
// Even if the file is not recognized as a "text file", we could still put its name into the indexers to make the filename become searchable, while leave the content to empty.
fileContents = nil
diff --git a/modules/indexer/code/elasticsearch/elasticsearch.go b/modules/indexer/code/elasticsearch/elasticsearch.go
index 9b11f56fb7..3903d77fe0 100644
--- a/modules/indexer/code/elasticsearch/elasticsearch.go
+++ b/modules/indexer/code/elasticsearch/elasticsearch.go
@@ -144,7 +144,7 @@ func (b *Indexer) addUpdate(ctx context.Context, batchWriter git.WriteCloserErro
fileContents, err := io.ReadAll(io.LimitReader(batchReader, size))
if err != nil {
return nil, err
- } else if !typesniffer.DetectContentType(fileContents, update.Filename).IsText() {
+ } else if !typesniffer.DetectContentType(fileContents).IsText() {
// FIXME: UTF-16 files will probably fail here
return nil, nil
}
diff --git a/modules/indexer/issues/bleve/bleve.go b/modules/indexer/issues/bleve/bleve.go
index cb98f722c5..8549ba8dfc 100644
--- a/modules/indexer/issues/bleve/bleve.go
+++ b/modules/indexer/issues/bleve/bleve.go
@@ -156,12 +156,11 @@ func (b *Indexer) Delete(_ context.Context, ids ...int64) error {
func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (*internal.SearchResult, error) {
var queries []query.Query
- tokens, err := options.Tokens()
- if err != nil {
- return nil, err
- }
-
- if len(tokens) > 0 {
+ if options.Keyword != "" {
+ tokens, err := options.Tokens()
+ if err != nil {
+ return nil, err
+ }
q := bleve.NewBooleanQuery()
for _, token := range tokens {
innerQ := bleve.NewDisjunctionQuery(
diff --git a/modules/indexer/issues/elasticsearch/elasticsearch.go b/modules/indexer/issues/elasticsearch/elasticsearch.go
index 311e92730e..d632a22b2a 100644
--- a/modules/indexer/issues/elasticsearch/elasticsearch.go
+++ b/modules/indexer/issues/elasticsearch/elasticsearch.go
@@ -149,13 +149,12 @@ func (b *Indexer) Delete(ctx context.Context, ids ...int64) error {
func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (*internal.SearchResult, error) {
query := elastic.NewBoolQuery()
- tokens, err := options.Tokens()
- if err != nil {
- return nil, err
- }
-
- if len(tokens) > 0 {
+ if options.Keyword != "" {
q := elastic.NewBoolQuery()
+ tokens, err := options.Tokens()
+ if err != nil {
+ return nil, err
+ }
for _, token := range tokens {
innerQ := elastic.NewMultiMatchQuery(token.Term, "content", "comments").FieldWithBoost("title", 2.0).TieBreaker(0.5)
if token.Fuzzy {
diff --git a/modules/indexer/issues/internal/qstring.go b/modules/indexer/issues/internal/qstring.go
index 348f7a564b..6b60b4c5f6 100644
--- a/modules/indexer/issues/internal/qstring.go
+++ b/modules/indexer/issues/internal/qstring.go
@@ -45,9 +45,12 @@ func (t *Tokenizer) next() (tk Token, err error) {
// skip all leading white space
for {
- if r, _, err = t.in.ReadRune(); err != nil || r != ' ' {
- break
+ if r, _, err = t.in.ReadRune(); err == nil && r == ' ' {
+ //nolint:staticcheck,wastedassign // SA4006 the variable is used after the loop
+ r, _, err = t.in.ReadRune()
+ continue
}
+ break
}
if err != nil {
return tk, err
@@ -104,17 +107,11 @@ nextEnd:
// Tokenize the keyword
func (o *SearchOptions) Tokens() (tokens []Token, err error) {
- if o.Keyword == "" {
- return nil, nil
- }
-
in := strings.NewReader(o.Keyword)
it := Tokenizer{in: in}
for token, err := it.next(); err == nil; token, err = it.next() {
- if token.Term != "" {
- tokens = append(tokens, token)
- }
+ tokens = append(tokens, token)
}
if err != nil && err != io.EOF {
return nil, err
diff --git a/modules/indexer/issues/internal/qstring_test.go b/modules/indexer/issues/internal/qstring_test.go
index eb4bdb306f..835491707c 100644
--- a/modules/indexer/issues/internal/qstring_test.go
+++ b/modules/indexer/issues/internal/qstring_test.go
@@ -41,36 +41,6 @@ var testOpts = []testIssueQueryStringOpt{
},
},
},
- {
- Keyword: "Hello World",
- Results: []Token{
- {
- Term: "Hello",
- Fuzzy: true,
- Kind: BoolOptShould,
- },
- {
- Term: "World",
- Fuzzy: true,
- Kind: BoolOptShould,
- },
- },
- },
- {
- Keyword: " Hello World ",
- Results: []Token{
- {
- Term: "Hello",
- Fuzzy: true,
- Kind: BoolOptShould,
- },
- {
- Term: "World",
- Fuzzy: true,
- Kind: BoolOptShould,
- },
- },
- },
{
Keyword: "+Hello +World",
Results: []Token{
@@ -186,68 +156,6 @@ var testOpts = []testIssueQueryStringOpt{
},
},
},
- {
- Keyword: "\\",
- Results: nil,
- },
- {
- Keyword: "\"",
- Results: nil,
- },
- {
- Keyword: "Hello \\",
- Results: []Token{
- {
- Term: "Hello",
- Fuzzy: true,
- Kind: BoolOptShould,
- },
- },
- },
- {
- Keyword: "\"\"",
- Results: nil,
- },
- {
- Keyword: "\" World \"",
- Results: []Token{
- {
- Term: " World ",
- Fuzzy: false,
- Kind: BoolOptShould,
- },
- },
- },
- {
- Keyword: "\"\" World \"\"",
- Results: []Token{
- {
- Term: "World",
- Fuzzy: true,
- Kind: BoolOptShould,
- },
- },
- },
- {
- Keyword: "Best \"Hello World\" Ever",
- Results: []Token{
- {
- Term: "Best",
- Fuzzy: true,
- Kind: BoolOptShould,
- },
- {
- Term: "Hello World",
- Fuzzy: false,
- Kind: BoolOptShould,
- },
- {
- Term: "Ever",
- Fuzzy: true,
- Kind: BoolOptShould,
- },
- },
- },
}
func TestIssueQueryString(t *testing.T) {
diff --git a/modules/indexer/issues/internal/tests/tests.go b/modules/indexer/issues/internal/tests/tests.go
index 46014994a0..b63957ff84 100644
--- a/modules/indexer/issues/internal/tests/tests.go
+++ b/modules/indexer/issues/internal/tests/tests.go
@@ -87,44 +87,14 @@ func TestIndexer(t *testing.T, indexer internal.Indexer) {
}
}
-func allResults(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
- assert.Len(t, result.Hits, len(data))
- assert.Equal(t, len(data), int(result.Total))
-}
-
var cases = []*testIndexerCase{
{
Name: "default",
SearchOptions: &internal.SearchOptions{},
- Expected: allResults,
- },
- {
- Name: "empty keyword",
- SearchOptions: &internal.SearchOptions{
- Keyword: "",
+ Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
+ assert.Len(t, result.Hits, len(data))
+ assert.Equal(t, len(data), int(result.Total))
},
- Expected: allResults,
- },
- {
- Name: "whitespace keyword",
- SearchOptions: &internal.SearchOptions{
- Keyword: " ",
- },
- Expected: allResults,
- },
- {
- Name: "dangling slash in keyword",
- SearchOptions: &internal.SearchOptions{
- Keyword: "\\",
- },
- Expected: allResults,
- },
- {
- Name: "dangling quote in keyword",
- SearchOptions: &internal.SearchOptions{
- Keyword: "\"",
- },
- Expected: allResults,
},
{
Name: "empty",
diff --git a/modules/log/event_writer.go b/modules/log/event_writer.go
index 32b5b582c5..4b77e488de 100644
--- a/modules/log/event_writer.go
+++ b/modules/log/event_writer.go
@@ -26,7 +26,6 @@ type WriterMode struct {
Flags Flags
Expression string
- Exclusion string
StacktraceLevel Level
diff --git a/modules/log/event_writer_base.go b/modules/log/event_writer_base.go
index 4de2b953c7..9189ca4e90 100644
--- a/modules/log/event_writer_base.go
+++ b/modules/log/event_writer_base.go
@@ -68,14 +68,6 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) {
}
}
- var exclusionRegexp *regexp.Regexp
- if b.Mode.Exclusion != "" {
- var err error
- if exclusionRegexp, err = regexp.Compile(b.Mode.Exclusion); err != nil {
- FallbackErrorf("unable to compile exclusion %q for writer %q: %v", b.Mode.Exclusion, b.Name, err)
- }
- }
-
handlePaused := func() {
if pause := b.GetPauseChan(); pause != nil {
select {
@@ -103,13 +95,6 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) {
continue
}
}
- if exclusionRegexp != nil {
- fileLineCaller := fmt.Sprintf("%s:%d:%s", event.Origin.Filename, event.Origin.Line, event.Origin.Caller)
- matched := exclusionRegexp.MatchString(fileLineCaller) || exclusionRegexp.MatchString(event.Origin.MsgSimpleText)
- if matched {
- continue
- }
- }
var err error
switch msg := event.Msg.(type) {
diff --git a/modules/log/event_writer_buffer_test.go b/modules/log/event_writer_buffer_test.go
index d1e37c3673..ba9455ba69 100644
--- a/modules/log/event_writer_buffer_test.go
+++ b/modules/log/event_writer_buffer_test.go
@@ -31,49 +31,3 @@ func TestBufferLogger(t *testing.T) {
logger.Close()
assert.Contains(t, bufferWriter.Buffer.String(), expected)
}
-
-func TestBufferLoggerWithExclusion(t *testing.T) {
- prefix := "ExclusionPrefix "
- level := log.INFO
- message := "something"
-
- bufferWriter := log.NewEventWriterBuffer("test-buffer", log.WriterMode{
- Level: level,
- Prefix: prefix,
- Exclusion: message,
- })
-
- logger := log.NewLoggerWithWriters(t.Context(), "test", bufferWriter)
-
- logger.SendLogEvent(&log.Event{
- Level: log.INFO,
- MsgSimpleText: message,
- })
- logger.Close()
- assert.NotContains(t, bufferWriter.Buffer.String(), message)
-}
-
-func TestBufferLoggerWithExpressionAndExclusion(t *testing.T) {
- prefix := "BothPrefix "
- level := log.INFO
- expression := ".*foo.*"
- exclusion := ".*bar.*"
-
- bufferWriter := log.NewEventWriterBuffer("test-buffer", log.WriterMode{
- Level: level,
- Prefix: prefix,
- Expression: expression,
- Exclusion: exclusion,
- })
-
- logger := log.NewLoggerWithWriters(t.Context(), "test", bufferWriter)
-
- logger.SendLogEvent(&log.Event{Level: log.INFO, MsgSimpleText: "foo expression"})
- logger.SendLogEvent(&log.Event{Level: log.INFO, MsgSimpleText: "bar exclusion"})
- logger.SendLogEvent(&log.Event{Level: log.INFO, MsgSimpleText: "foo bar both"})
- logger.SendLogEvent(&log.Event{Level: log.INFO, MsgSimpleText: "none"})
- logger.Close()
-
- assert.Contains(t, bufferWriter.Buffer.String(), "foo expression")
- assert.NotContains(t, bufferWriter.Buffer.String(), "bar")
-}
diff --git a/modules/log/logger_test.go b/modules/log/logger_test.go
index 99045b0f4f..6d6ceb69d7 100644
--- a/modules/log/logger_test.go
+++ b/modules/log/logger_test.go
@@ -143,19 +143,3 @@ func TestLoggerExpressionFilter(t *testing.T) {
assert.Equal(t, []string{"foo\n", "foo bar\n", "by filename\n"}, w1.GetLogs())
}
-
-func TestLoggerExclusionFilter(t *testing.T) {
- logger := NewLoggerWithWriters(t.Context(), "test")
-
- w1 := newDummyWriter("dummy-1", DEBUG, 0)
- w1.Mode.Exclusion = "foo.*"
- logger.AddWriters(w1)
-
- logger.Info("foo")
- logger.Info("bar")
- logger.Info("foo bar")
- logger.SendLogEvent(&Event{Level: INFO, Filename: "foo.go", MsgSimpleText: "by filename"})
- logger.Close()
-
- assert.Equal(t, []string{"bar\n"}, w1.GetLogs())
-}
diff --git a/modules/markup/markdown/goldmark.go b/modules/markup/markdown/goldmark.go
index 67d81488fd..d229afa8e3 100644
--- a/modules/markup/markdown/goldmark.go
+++ b/modules/markup/markdown/goldmark.go
@@ -9,7 +9,6 @@ import (
"strings"
"forgejo.org/modules/markup"
- markdownutil "forgejo.org/modules/markup/markdown/util"
"forgejo.org/modules/setting"
"github.com/yuin/goldmark/ast"
@@ -36,8 +35,8 @@ func (g *ASTTransformer) applyElementDir(n ast.Node) {
func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc parser.Context) {
firstChild := node.FirstChild()
tocMode := ""
- ctx := pc.Get(markdownutil.RenderContextKey).(*markup.RenderContext)
- rc := pc.Get(markdownutil.RenderConfigKey).(*RenderConfig)
+ ctx := pc.Get(renderContextKey).(*markup.RenderContext)
+ rc := pc.Get(renderConfigKey).(*RenderConfig)
tocList := make([]markup.Header, 0, 20)
if rc.yamlNode != nil {
diff --git a/modules/markup/markdown/markdown.go b/modules/markup/markdown/markdown.go
index 2b19e0f1c9..e811d29994 100644
--- a/modules/markup/markdown/markdown.go
+++ b/modules/markup/markdown/markdown.go
@@ -16,7 +16,6 @@ import (
"forgejo.org/modules/markup/common"
"forgejo.org/modules/markup/markdown/callout"
"forgejo.org/modules/markup/markdown/math"
- markdownutil "forgejo.org/modules/markup/markdown/util"
"forgejo.org/modules/setting"
giteautil "forgejo.org/modules/util"
@@ -35,6 +34,11 @@ var (
specMarkdownOnce sync.Once
)
+var (
+ renderContextKey = parser.NewContextKey()
+ renderConfigKey = parser.NewContextKey()
+)
+
type limitWriter struct {
w io.Writer
sum int64
@@ -60,7 +64,7 @@ func (l *limitWriter) Write(data []byte) (int, error) {
// newParserContext creates a parser.Context with the render context set
func newParserContext(ctx *markup.RenderContext) parser.Context {
pc := parser.NewContext(parser.WithIDs(newPrefixedIDs()))
- pc.Set(markdownutil.RenderContextKey, ctx)
+ pc.Set(renderContextKey, ctx)
return pc
}
@@ -188,7 +192,7 @@ func actualRender(ctx *markup.RenderContext, input io.Reader, output io.Writer)
}
rc.metaLength = metaLength
- pc.Set(markdownutil.RenderConfigKey, rc)
+ pc.Set(renderConfigKey, rc)
if err := converter.Convert(buf, lw, parser.WithContext(pc)); err != nil {
log.Error("Unable to render: %v", err)
diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go
index c854861031..f7955115e0 100644
--- a/modules/markup/markdown/markdown_test.go
+++ b/modules/markup/markdown/markdown_test.go
@@ -561,14 +561,6 @@ func TestMathBlock(t *testing.T) {
"test $$a$$",
`
test a
` + nl,
},
- {
- `\[
-[\triangle ABC] = \sqrt{s(s-a)(s-b)(s-c)}
-\]`,
- `[
-[\triangle ABC] = \sqrt{s(s-a)(s-b)(s-c)}
-]
` + nl,
- },
}
for _, test := range testcases {
@@ -576,32 +568,6 @@ func TestMathBlock(t *testing.T) {
require.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
assert.Equal(t, template.HTML(test.expected), res, "Unexpected result in testcase %q", test.testcase)
}
-
- t.Run("Wiki context", func(t *testing.T) {
- testcases := []struct {
- testcase string
- expected string
- }{
- {
- "$a$",
- `a
` + nl,
- },
- {
- `\[
-[\triangle ABC] = \sqrt{s(s-a)(s-b)(s-c)}
-\]`,
- `
-[\triangle ABC] = \sqrt{s(s-a)(s-b)(s-c)}
-
` + nl,
- },
- }
-
- for _, test := range testcases {
- res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext, IsWiki: true}, test.testcase)
- require.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
- assert.Equal(t, template.HTML(test.expected), res, "Unexpected result in testcase %q", test.testcase)
- }
- })
}
func TestFootnote(t *testing.T) {
diff --git a/modules/markup/markdown/math/block_parser.go b/modules/markup/markdown/math/block_parser.go
index b0fe1d588a..527df84975 100644
--- a/modules/markup/markdown/math/block_parser.go
+++ b/modules/markup/markdown/math/block_parser.go
@@ -6,9 +6,6 @@ package math
import (
"bytes"
- "forgejo.org/modules/markup"
- markdownutil "forgejo.org/modules/markup/markdown/util"
-
"github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/text"
@@ -64,13 +61,6 @@ func (b *blockParser) Open(parent ast.Node, reader text.Reader, pc parser.Contex
return node, parser.Close | parser.NoChildren
}
- ctx := pc.Get(markdownutil.RenderContextKey).(*markup.RenderContext)
- if ctx.IsWiki {
- reader.Advance(segment.Len() - 1)
- segment.Start += 2
- node.Lines().Append(segment)
- return node, parser.NoChildren
- }
return nil, parser.NoChildren
}
diff --git a/modules/markup/markdown/util/text.go b/modules/markup/markdown/util/text.go
index db6e432e79..8a42e5835b 100644
--- a/modules/markup/markdown/util/text.go
+++ b/modules/markup/markdown/util/text.go
@@ -7,7 +7,6 @@ import (
"bytes"
"github.com/yuin/goldmark/ast"
- "github.com/yuin/goldmark/parser"
)
func textOfChildren(n ast.Node, src []byte, b *bytes.Buffer) {
@@ -25,8 +24,3 @@ func Text(n ast.Node, src []byte) []byte {
textOfChildren(n, src, &b)
return b.Bytes()
}
-
-var (
- RenderContextKey = parser.NewContextKey()
- RenderConfigKey = parser.NewContextKey()
-)
diff --git a/modules/packages/rpm/metadata.go b/modules/packages/rpm/metadata.go
index 503b7b1a24..4af9af620f 100644
--- a/modules/packages/rpm/metadata.go
+++ b/modules/packages/rpm/metadata.go
@@ -232,10 +232,9 @@ func getEntries(h *rpmutils.RpmHeader, namesTag, versionsTag, flagsTag int, repo
case "alt":
for i := range names {
e := &Entry{
- Name: names[i],
AltFlags: uint32(flags[i]),
- Version: versions[i],
}
+ e.Version = versions[i]
entries = append(entries, e)
}
}
diff --git a/modules/setting/incoming_email.go b/modules/setting/incoming_email.go
index a890a4a328..e592220de6 100644
--- a/modules/setting/incoming_email.go
+++ b/modules/setting/incoming_email.go
@@ -44,14 +44,9 @@ func loadIncomingEmailFrom(rootCfg ConfigProvider) {
if sec.HasKey("USER") && !sec.HasKey("USERNAME") {
IncomingEmail.Username = sec.Key("USER").String()
}
-
if sec.HasKey("PASSWD") && !sec.HasKey("PASSWORD") {
- sec.Key("PASSWORD").SetValue(sec.Key("PASSWD").String())
+ IncomingEmail.Password = sec.Key("PASSWD").String()
}
- if sec.HasKey("PASSWD_URI") && !sec.HasKey("PASSWORD_URI") {
- sec.Key("PASSWORD_URI").SetValue(sec.Key("PASSWD_URI").String())
- }
- IncomingEmail.Password = loadSecret(sec, "PASSWORD_URI", "PASSWORD")
// Infer Port if not set
if IncomingEmail.Port == 0 {
diff --git a/modules/setting/incoming_email_test.go b/modules/setting/incoming_email_test.go
index 4ea740bafd..6d181cae3c 100644
--- a/modules/setting/incoming_email_test.go
+++ b/modules/setting/incoming_email_test.go
@@ -4,8 +4,6 @@
package setting
import (
- "os"
- "path/filepath"
"testing"
"github.com/stretchr/testify/assert"
@@ -37,22 +35,6 @@ func Test_loadIncomingEmailFrom(t *testing.T) {
assert.Equal(t, "y0u'll n3v3r gUess th1S!!1", IncomingEmail.Password)
})
- t.Run("Secrets", func(t *testing.T) {
- uri := filepath.Join(t.TempDir(), "email_incoming_password")
-
- if err := os.WriteFile(uri, []byte("th1S gUess n3v3r y0u'll!!1"), 0o644); err != nil {
- t.Fatal(err)
- }
-
- cfg, sec := makeBaseConfig()
- sec.NewKey("PASSWORD_URI", "file:"+uri)
-
- IncomingEmail.Password = ""
- loadIncomingEmailFrom(cfg)
-
- assert.Equal(t, "th1S gUess n3v3r y0u'll!!1", IncomingEmail.Password)
- })
-
t.Run("Port settings", func(t *testing.T) {
t.Run("no port, no tls", func(t *testing.T) {
defer resetIncomingEmailPort()()
diff --git a/modules/setting/log.go b/modules/setting/log.go
index 6d069d0e9c..0747ac4dac 100644
--- a/modules/setting/log.go
+++ b/modules/setting/log.go
@@ -133,7 +133,6 @@ func loadLogModeByName(rootCfg ConfigProvider, loggerName, modeName string) (wri
writerMode.StacktraceLevel = log.LevelFromString(ConfigInheritedKeyString(sec, "STACKTRACE_LEVEL", Log.StacktraceLogLevel.String()))
writerMode.Prefix = ConfigInheritedKeyString(sec, "PREFIX")
writerMode.Expression = ConfigInheritedKeyString(sec, "EXPRESSION")
- writerMode.Exclusion = ConfigInheritedKeyString(sec, "EXCLUSION")
// flags are updated and set below
switch writerType {
diff --git a/modules/setting/log_test.go b/modules/setting/log_test.go
index 223bd68285..eda6dc36af 100644
--- a/modules/setting/log_test.go
+++ b/modules/setting/log_test.go
@@ -44,7 +44,6 @@ func TestLogConfigDefault(t *testing.T) {
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@@ -84,7 +83,6 @@ logger.xorm.MODE =
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@@ -123,7 +121,6 @@ MODE = console
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@@ -171,7 +168,6 @@ ACCESS = file
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@@ -195,7 +191,6 @@ ACCESS = file
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "none",
"Level": "info",
"Prefix": "",
@@ -262,7 +257,6 @@ STDERR = true
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "stdflags",
"Level": "warn",
"Prefix": "",
@@ -276,7 +270,6 @@ STDERR = true
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "stdflags",
"Level": "error",
"Prefix": "",
@@ -294,7 +287,6 @@ STDERR = true
"BufferLen": 10000,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "none",
"Level": "warn",
"Prefix": "",
@@ -331,7 +323,6 @@ MODE = file
LEVEL = error
STACKTRACE_LEVEL = fatal
EXPRESSION = filter
-EXCLUSION = not
FLAGS = medfile
PREFIX = "[Prefix] "
FILE_NAME = file-xxx.log
@@ -350,7 +341,6 @@ COMPRESSION_LEVEL = 4
"BufferLen": 10,
"Colorize": false,
"Expression": "",
- "Exclusion": "",
"Flags": "stdflags",
"Level": "info",
"Prefix": "",
@@ -370,7 +360,6 @@ COMPRESSION_LEVEL = 4
"BufferLen": 10,
"Colorize": false,
"Expression": "filter",
- "Exclusion": "not",
"Flags": "medfile",
"Level": "error",
"Prefix": "[Prefix] ",
diff --git a/modules/setting/mailer.go b/modules/setting/mailer.go
index b43484a90f..9c004c6ce0 100644
--- a/modules/setting/mailer.go
+++ b/modules/setting/mailer.go
@@ -147,10 +147,6 @@ func loadMailerFrom(rootCfg ConfigProvider) {
if sec.HasKey("PASSWORD") && !sec.HasKey("PASSWD") {
sec.Key("PASSWD").SetValue(sec.Key("PASSWORD").String())
}
- if sec.HasKey("PASSWORD_URI") && !sec.HasKey("PASSWD_URI") {
- sec.Key("PASSWD_URI").SetValue(sec.Key("PASSWORD_URI").String())
- }
- sec.Key("PASSWD").SetValue(loadSecret(sec, "PASSWD_URI", "PASSWD"))
// Set default values & validate
sec.Key("NAME").MustString(AppName)
diff --git a/modules/setting/mailer_test.go b/modules/setting/mailer_test.go
index 47eaf3ffbb..4523cc91dd 100644
--- a/modules/setting/mailer_test.go
+++ b/modules/setting/mailer_test.go
@@ -4,8 +4,6 @@
package setting
import (
- "os"
- "path/filepath"
"testing"
"github.com/stretchr/testify/assert"
@@ -54,24 +52,6 @@ func Test_loadMailerFrom(t *testing.T) {
assert.Equal(t, "y0u'll n3v3r gUess th1S!!1", MailService.Passwd)
})
- t.Run("Secrets", func(t *testing.T) {
- uri := filepath.Join(t.TempDir(), "mailer_passwd")
-
- if err := os.WriteFile(uri, []byte("th1S gUess n3v3r y0u'll!!1"), 0o644); err != nil {
- t.Fatal(err)
- }
-
- cfg, _ := NewConfigProviderFromData("")
- sec := cfg.Section("mailer")
- sec.NewKey("ENABLED", "true")
- sec.NewKey("PASSWD_URI", "file:"+uri)
-
- MailService.Passwd = ""
- loadMailerFrom(cfg)
-
- assert.Equal(t, "th1S gUess n3v3r y0u'll!!1", MailService.Passwd)
- })
-
t.Run("sendmail argument sanitization", func(t *testing.T) {
cfg, _ := NewConfigProviderFromData("")
sec := cfg.Section("mailer")
diff --git a/modules/structs/activitypub.go b/modules/structs/activitypub.go
index 0cc257ff95..117eb0bed2 100644
--- a/modules/structs/activitypub.go
+++ b/modules/structs/activitypub.go
@@ -1,5 +1,4 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
-// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
@@ -8,15 +7,3 @@ package structs
type ActivityPub struct {
Context string `json:"@context"`
}
-
-type APRemoteFollowOption struct {
- Target string `json:"target"`
-}
-
-type APPersonFollowItem struct {
- ActorID string `json:"actor_id"`
- Note string `json:"note"`
-
- OriginalURL string `json:"original_url"`
- OriginalItem string `json:"original_item"`
-}
diff --git a/modules/structs/attachment.go b/modules/structs/attachment.go
index 746f618cf0..0a3d4140c2 100644
--- a/modules/structs/attachment.go
+++ b/modules/structs/attachment.go
@@ -22,12 +22,6 @@ type Attachment struct {
Type string `json:"type"`
}
-// WebAttachment the generic attachment with mime type
-type WebAttachment struct {
- *Attachment
- MimeType string `json:"mime_type"`
-}
-
// EditAttachmentOptions options for editing attachments
// swagger:model
type EditAttachmentOptions struct {
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 42b4bad83c..02b175e6f6 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -188,7 +188,6 @@ func NewFuncMap() template.FuncMap {
"RenderMarkdownToHtml": RenderMarkdownToHtml,
"RenderLabel": RenderLabel,
"RenderLabels": RenderLabels,
- "RenderUser": RenderUser,
"RenderReviewRequest": RenderReviewRequest,
// -----------------------------------------------------------------
diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go
index 48f4eb04a3..a4d7a82eea 100644
--- a/modules/templates/util_render.go
+++ b/modules/templates/util_render.go
@@ -7,7 +7,6 @@ import (
"context"
"encoding/hex"
"fmt"
- "html"
"html/template"
"math"
"net/url"
@@ -16,7 +15,6 @@ import (
"unicode"
issues_model "forgejo.org/models/issues"
- user_model "forgejo.org/models/user"
"forgejo.org/modules/emoji"
"forgejo.org/modules/log"
"forgejo.org/modules/markup"
@@ -28,7 +26,7 @@ import (
// RenderCommitMessage renders commit message with XSS-safe and special links.
func RenderCommitMessage(ctx context.Context, msg string, metas map[string]string) template.HTML {
- cleanMsg := html.EscapeString(msg)
+ cleanMsg := template.HTMLEscapeString(msg)
// we can safely assume that it will not return any error, since there
// shouldn't be any special HTML.
fullMessage, err := markup.RenderCommitMessage(&markup.RenderContext{
@@ -65,7 +63,7 @@ func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string,
Ctx: ctx,
DefaultLink: urlDefault,
Metas: metas,
- }, html.EscapeString(msgLine))
+ }, template.HTMLEscapeString(msgLine))
if err != nil {
log.Error("RenderCommitMessageSubject: %v", err)
return template.HTML("")
@@ -90,7 +88,7 @@ func RenderCommitBody(ctx context.Context, msg string, metas map[string]string)
renderedMessage, err := markup.RenderCommitMessage(&markup.RenderContext{
Ctx: ctx,
Metas: metas,
- }, html.EscapeString(msgLine))
+ }, template.HTMLEscapeString(msgLine))
if err != nil {
log.Error("RenderCommitMessage: %v", err)
return ""
@@ -124,7 +122,7 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string)
renderedText, err := markup.RenderIssueTitle(&markup.RenderContext{
Ctx: ctx,
Metas: metas,
- }, html.EscapeString(text))
+ }, template.HTMLEscapeString(text))
if err != nil {
log.Error("RenderIssueTitle: %v", err)
return template.HTML("")
@@ -134,7 +132,7 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string)
// RenderRefIssueTitle renders referenced issue/pull title with defined post processors
func RenderRefIssueTitle(ctx context.Context, text string) template.HTML {
- renderedText, err := markup.RenderRefIssueTitle(&markup.RenderContext{Ctx: ctx}, html.EscapeString(text))
+ renderedText, err := markup.RenderRefIssueTitle(&markup.RenderContext{Ctx: ctx}, template.HTMLEscapeString(text))
if err != nil {
log.Error("RenderRefIssueTitle: %v", err)
return ""
@@ -152,7 +150,7 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m
labelScope = label.ExclusiveScope()
)
- description := emoji.ReplaceAliases(html.EscapeString(label.Description))
+ description := emoji.ReplaceAliases(template.HTMLEscapeString(label.Description))
if label.IsArchived() {
archivedCSSClass = "archived-label"
@@ -214,7 +212,7 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m
// RenderEmoji renders html text with emoji post processors
func RenderEmoji(ctx context.Context, text string) template.HTML {
renderedText, err := markup.RenderEmoji(&markup.RenderContext{Ctx: ctx},
- html.EscapeString(text))
+ template.HTMLEscapeString(text))
if err != nil {
log.Error("RenderEmoji: %v", err)
return template.HTML("")
@@ -265,20 +263,10 @@ func RenderLabels(ctx context.Context, locale translation.Locale, labels []*issu
return template.HTML(htmlCode)
}
-func RenderUser(ctx context.Context, user user_model.User) template.HTML {
- if user.ID > 0 {
- return template.HTML(fmt.Sprintf(
- "%s",
- user.HomeLink(), html.EscapeString(user.GetDisplayName())))
- }
- return template.HTML(fmt.Sprintf("%s",
- html.EscapeString(user.GetDisplayName())))
-}
-
func RenderReviewRequest(users []issues_model.RequestReviewTarget) template.HTML {
usernames := make([]string, 0, len(users))
for _, user := range users {
- usernames = append(usernames, html.EscapeString(user.Name()))
+ usernames = append(usernames, template.HTMLEscapeString(user.Name()))
}
htmlCode := ``
diff --git a/modules/templates/util_render_test.go b/modules/templates/util_render_test.go
index a5fb18642a..62e063213c 100644
--- a/modules/templates/util_render_test.go
+++ b/modules/templates/util_render_test.go
@@ -11,9 +11,6 @@ import (
"forgejo.org/models/db"
issues_model "forgejo.org/models/issues"
"forgejo.org/models/unittest"
- user_model "forgejo.org/models/user"
- "forgejo.org/modules/setting"
- "forgejo.org/modules/test"
"forgejo.org/modules/translation"
"github.com/stretchr/testify/assert"
@@ -218,51 +215,9 @@ func TestRenderLabels(t *testing.T) {
tr := &translation.MockLocale{}
label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
- labelScoped := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 7})
- labelMalicious := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 11})
- labelArchived := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 12})
- rendered := RenderLabels(db.DefaultContext, tr, []*issues_model.Label{label}, "user2/repo1", false)
- assert.Contains(t, rendered, "user2/repo1/issues?labels=1")
- assert.Contains(t, rendered, ">label1<")
- assert.Contains(t, rendered, "title='First label'")
- rendered = RenderLabels(db.DefaultContext, tr, []*issues_model.Label{label}, "user2/repo1", true)
- assert.Contains(t, rendered, "user2/repo1/pulls?labels=1")
- assert.Contains(t, rendered, ">label1<")
- rendered = RenderLabels(db.DefaultContext, tr, []*issues_model.Label{labelScoped}, "user2/repo1", false)
- assert.Contains(t, rendered, "user2/repo1/issues?labels=7")
- assert.Contains(t, rendered, ">scope<")
- assert.Contains(t, rendered, ">label1<")
- rendered = RenderLabels(db.DefaultContext, tr, []*issues_model.Label{labelMalicious}, "user2/repo1", false)
- assert.Contains(t, rendered, "user2/repo1/issues?labels=11")
- assert.Contains(t, rendered, "> <script>malicious</script> <")
- assert.Contains(t, rendered, ">'?&<")
- assert.Contains(t, rendered, "title='Malicious label ' <script>malicious</script>'")
- rendered = RenderLabels(db.DefaultContext, tr, []*issues_model.Label{labelArchived}, "user2/repo1", false)
- assert.Contains(t, rendered, "user2/repo1/issues?labels=12")
- assert.Contains(t, rendered, ">archived label<><")
- assert.Contains(t, rendered, "title='repo.issues.archived_label_description'")
-}
-
-func TestRenderUser(t *testing.T) {
- unittest.PrepareTestEnv(t)
-
- user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
- org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3})
- ghost := user_model.NewGhostUser()
-
- assert.Contains(t, RenderUser(db.DefaultContext, *user),
- "user2")
- assert.Contains(t, RenderUser(db.DefaultContext, *org),
- "org3")
- assert.Contains(t, RenderUser(db.DefaultContext, *ghost),
- "Ghost")
-
- defer test.MockVariableValue(&setting.UI.DefaultShowFullName, true)()
- assert.Contains(t, RenderUser(db.DefaultContext, *user),
- "< U<se>r Tw<o > ><")
- assert.Contains(t, RenderUser(db.DefaultContext, *org),
- "<<<< >> >> > >> > >>> >>")
- assert.Contains(t, RenderUser(db.DefaultContext, *ghost),
- "Ghost")
+ assert.Contains(t, RenderLabels(db.DefaultContext, tr, []*issues_model.Label{label}, "user2/repo1", false),
+ "user2/repo1/issues?labels=1")
+ assert.Contains(t, RenderLabels(db.DefaultContext, tr, []*issues_model.Label{label}, "user2/repo1", true),
+ "user2/repo1/pulls?labels=1")
}
diff --git a/modules/test/distant_federation_server_mock.go b/modules/test/distant_federation_server_mock.go
index ea8a69e9b4..9bd908e2b9 100644
--- a/modules/test/distant_federation_server_mock.go
+++ b/modules/test/distant_federation_server_mock.go
@@ -10,79 +10,56 @@ import (
"net/http/httptest"
"strings"
"testing"
-
- "forgejo.org/modules/util"
)
type FederationServerMockPerson struct {
- ID int64
- Name string
- PubKey string
- PrivKey string
+ ID int64
+ Name string
+ PubKey string
}
type FederationServerMockRepository struct {
ID int64
}
-type ApActorMock struct {
- PrivKey string
- PubKey string
-}
type FederationServerMock struct {
- ApActor ApActorMock
Persons []FederationServerMockPerson
Repositories []FederationServerMockRepository
LastPost string
}
func NewFederationServerMockPerson(id int64, name string) FederationServerMockPerson {
- priv, pub, _ := util.GenerateKeyPair(3072)
return FederationServerMockPerson{
- ID: id,
- Name: name,
- PubKey: pub,
- PrivKey: priv,
+ ID: id,
+ Name: name,
+ PubKey: `"-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA18H5s7N6ItZUAh9tneII\nIuZdTTa3cZlLa/9ejWAHTkcp3WLW+/zbsumlMrWYfBy2/yTm56qasWt38iY4D6ul\n` +
+ `CPiwhAqX3REvVq8tM79a2CEqZn9ka6vuXoDgBg/sBf/BUWqf7orkjUXwk/U0Egjf\nk5jcurF4vqf1u+rlAHH37dvSBaDjNj6Qnj4OP12bjfaY/yvs7+jue/eNXFHjzN4E\n` +
+ `T2H4B/yeKTJ4UuAwTlLaNbZJul2baLlHelJPAsxiYaziVuV5P+IGWckY6RSerRaZ\nAkc4mmGGtjAyfN9aewe+lNVfwS7ElFx546PlLgdQgjmeSwLX8FWxbPE5A/PmaXCs\n` +
+ `nx+nou+3dD7NluULLtdd7K+2x02trObKXCAzmi5/Dc+yKTzpFqEz+hLNCz7TImP/\ncK//NV9Q+X67J9O27baH9R9ZF4zMw8rv2Pg0WLSw1z7lLXwlgIsDapeMCsrxkVO4\n` +
+ `LXX5AQ1xQNtlssnVoUBqBrvZsX2jUUKUocvZqMGuE4hfAgMBAAE=\n-----END PUBLIC KEY-----\n"`,
}
}
-func (p *FederationServerMockPerson) KeyID(host string) string {
- return fmt.Sprintf("%[1]v/api/v1/activitypub/user-id/%[2]v#main-key", host, p.ID)
-}
-
func NewFederationServerMockRepository(id int64) FederationServerMockRepository {
return FederationServerMockRepository{
ID: id,
}
}
-func NewApActorMock() ApActorMock {
- priv, pub, _ := util.GenerateKeyPair(1024)
- return ApActorMock{
- PrivKey: priv,
- PubKey: pub,
- }
-}
-
-func (u *ApActorMock) KeyID(host string) string {
- return fmt.Sprintf("%[1]v/api/v1/activitypub/actor#main-key", host)
-}
-
func (p FederationServerMockPerson) marshal(host string) string {
return fmt.Sprintf(`{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1"],`+
- `"id":"http://%[1]v/api/v1/activitypub/user-id/%[2]v",`+
+ `"id":"http://%[1]v/api/activitypub/user-id/%[2]v",`+
`"type":"Person",`+
`"icon":{"type":"Image","mediaType":"image/png","url":"http://%[1]v/avatars/1bb05d9a5f6675ed0272af9ea193063c"},`+
`"url":"http://%[1]v/%[2]v",`+
- `"inbox":"http://%[1]v/api/v1/activitypub/user-id/%[2]v/inbox",`+
- `"outbox":"http://%[1]v/api/v1/activitypub/user-id/%[2]v/outbox",`+
+ `"inbox":"http://%[1]v/api/activitypub/user-id/%[2]v/inbox",`+
+ `"outbox":"http://%[1]v/api/activitypub/user-id/%[2]v/outbox",`+
`"preferredUsername":"%[3]v",`+
- `"publicKey":{"id":"http://%[1]v/api/v1/activitypub/user-id/%[2]v#main-key",`+
- `"owner":"http://%[1]v/api/v1/activitypub/user-id/%[2]v",`+
- `"publicKeyPem":%[4]q}}`, host, p.ID, p.Name, p.PubKey)
+ `"publicKey":{"id":"http://%[1]v/api/activitypub/user-id/%[2]v#main-key",`+
+ `"owner":"http://%[1]v/api/activitypub/user-id/%[2]v",`+
+ `"publicKeyPem":%[4]v}}`, host, p.ID, p.Name, p.PubKey)
}
func NewFederationServerMock() *FederationServerMock {
return &FederationServerMock{
- ApActor: NewApActorMock(),
Persons: []FederationServerMockPerson{
NewFederationServerMockPerson(15, "stargoose1"),
NewFederationServerMockPerson(30, "stargoose2"),
@@ -94,18 +71,8 @@ func NewFederationServerMock() *FederationServerMock {
}
}
-func (mock *FederationServerMock) recordLastPost(t *testing.T, req *http.Request) {
- buf := new(strings.Builder)
- _, err := io.Copy(buf, req.Body)
- if err != nil {
- t.Errorf("Error reading body: %q", err)
- }
- mock.LastPost = strings.ReplaceAll(buf.String(), req.Host, "DISTANT_FEDERATION_HOST")
-}
-
func (mock *FederationServerMock) DistantServer(t *testing.T) *httptest.Server {
federatedRoutes := http.NewServeMux()
-
federatedRoutes.HandleFunc("/.well-known/nodeinfo",
func(res http.ResponseWriter, req *http.Request) {
// curl -H "Accept: application/json" https://federated-repo.prod.meissa.de/.well-known/nodeinfo
@@ -120,28 +87,30 @@ func (mock *FederationServerMock) DistantServer(t *testing.T) *httptest.Server {
`"protocols":["activitypub"],"services":{"inbound":[],"outbound":["rss2.0"]},`+
`"openRegistrations":true,"usage":{"users":{"total":14,"activeHalfyear":2}},"metadata":{}}`)
})
-
for _, person := range mock.Persons {
federatedRoutes.HandleFunc(fmt.Sprintf("/api/v1/activitypub/user-id/%v", person.ID),
func(res http.ResponseWriter, req *http.Request) {
// curl -H "Accept: application/json" https://federated-repo.prod.meissa.de/api/v1/activitypub/user-id/2
fmt.Fprint(res, person.marshal(req.Host))
})
- federatedRoutes.HandleFunc(fmt.Sprintf("POST /api/v1/activitypub/user-id/%v/inbox", person.ID),
- func(res http.ResponseWriter, req *http.Request) {
- mock.recordLastPost(t, req)
- })
}
-
for _, repository := range mock.Repositories {
- federatedRoutes.HandleFunc(fmt.Sprintf("POST /api/v1/activitypub/repository-id/%v/inbox", repository.ID),
+ federatedRoutes.HandleFunc(fmt.Sprintf("/api/v1/activitypub/repository-id/%v/inbox", repository.ID),
func(res http.ResponseWriter, req *http.Request) {
- mock.recordLastPost(t, req)
+ if req.Method != "POST" {
+ t.Errorf("POST expected at: %q", req.URL.EscapedPath())
+ }
+ buf := new(strings.Builder)
+ _, err := io.Copy(buf, req.Body)
+ if err != nil {
+ t.Errorf("Error reading body: %q", err)
+ }
+ mock.LastPost = buf.String()
})
}
federatedRoutes.HandleFunc("/",
func(res http.ResponseWriter, req *http.Request) {
- t.Errorf("Unhandled %v request: %q", req.Method, req.URL.EscapedPath())
+ t.Errorf("Unhandled request: %q", req.URL.EscapedPath())
})
federatedSrv := httptest.NewServer(federatedRoutes)
return federatedSrv
diff --git a/modules/typesniffer/typesniffer.go b/modules/typesniffer/typesniffer.go
index 8cb1513a88..262feb2b05 100644
--- a/modules/typesniffer/typesniffer.go
+++ b/modules/typesniffer/typesniffer.go
@@ -124,7 +124,7 @@ func (ct SniffedType) GetMimeType() string {
}
// DetectContentType extends http.DetectContentType with more content types. Defaults to text/unknown if input is empty.
-func DetectContentType(data []byte, filename string) SniffedType {
+func DetectContentType(data []byte) SniffedType {
if len(data) == 0 {
return SniffedType{"text/unknown"}
}
@@ -176,13 +176,6 @@ func DetectContentType(data []byte, filename string) SniffedType {
}
}
- if ct == "application/octet-stream" &&
- filename != "" &&
- !strings.HasSuffix(strings.ToUpper(filename), ".LCOM") &&
- bytes.Contains(data, []byte("(DEFINE-FILE-INFO ")) {
- ct = "text/vnd.interlisp"
- }
-
// GLTF is unsupported by http.DetectContentType
// hexdump -n 4 -C glTF.glb
if bytes.HasPrefix(data, []byte("glTF")) {
@@ -193,7 +186,7 @@ func DetectContentType(data []byte, filename string) SniffedType {
}
// DetectContentTypeFromReader guesses the content type contained in the reader.
-func DetectContentTypeFromReader(r io.Reader, filename string) (SniffedType, error) {
+func DetectContentTypeFromReader(r io.Reader) (SniffedType, error) {
buf := make([]byte, sniffLen)
n, err := util.ReadAtMost(r, buf)
if err != nil {
@@ -201,5 +194,5 @@ func DetectContentTypeFromReader(r io.Reader, filename string) (SniffedType, err
}
buf = buf[:n]
- return DetectContentType(buf, filename), nil
+ return DetectContentType(buf), nil
}
diff --git a/modules/typesniffer/typesniffer_test.go b/modules/typesniffer/typesniffer_test.go
index d2b7ed4f21..176d3658bb 100644
--- a/modules/typesniffer/typesniffer_test.go
+++ b/modules/typesniffer/typesniffer_test.go
@@ -16,63 +16,63 @@ import (
func TestDetectContentTypeLongerThanSniffLen(t *testing.T) {
// Pre-condition: Shorter than sniffLen detects SVG.
- assert.Equal(t, "image/svg+xml", DetectContentType([]byte(``), "").contentType)
+ assert.Equal(t, "image/svg+xml", DetectContentType([]byte(``)).contentType)
// Longer than sniffLen detects something else.
- assert.NotEqual(t, "image/svg+xml", DetectContentType([]byte(``), "").contentType)
+ assert.NotEqual(t, "image/svg+xml", DetectContentType([]byte(``)).contentType)
}
func TestIsTextFile(t *testing.T) {
- assert.True(t, DetectContentType([]byte{}, "").IsText())
- assert.True(t, DetectContentType([]byte("lorem ipsum"), "").IsText())
+ assert.True(t, DetectContentType([]byte{}).IsText())
+ assert.True(t, DetectContentType([]byte("lorem ipsum")).IsText())
}
func TestIsSvgImage(t *testing.T) {
- assert.True(t, DetectContentType([]byte(""), "").IsSvgImage())
- assert.True(t, DetectContentType([]byte(" "), "").IsSvgImage())
- assert.True(t, DetectContentType([]byte(``), "").IsSvgImage())
- assert.True(t, DetectContentType([]byte(``), "").IsSvgImage())
+ assert.True(t, DetectContentType([]byte("")).IsSvgImage())
+ assert.True(t, DetectContentType([]byte(" ")).IsSvgImage())
+ assert.True(t, DetectContentType([]byte(``)).IsSvgImage())
+ assert.True(t, DetectContentType([]byte(``)).IsSvgImage())
assert.True(t, DetectContentType([]byte(`
- `), "").IsSvgImage())
+ `)).IsSvgImage())
assert.True(t, DetectContentType([]byte(`
- `), "").IsSvgImage())
+ `)).IsSvgImage())
assert.True(t, DetectContentType([]byte(`
- `), "").IsSvgImage())
+ `)).IsSvgImage())
assert.True(t, DetectContentType([]byte(`
- `), "").IsSvgImage())
+ `)).IsSvgImage())
assert.True(t, DetectContentType([]byte(`
- `), "").IsSvgImage())
+ `)).IsSvgImage())
assert.True(t, DetectContentType([]byte(`
- `), "").IsSvgImage())
+ `)).IsSvgImage())
assert.True(t, DetectContentType([]byte(`
- `), "").IsSvgImage())
+ `)).IsSvgImage())
assert.True(t, DetectContentType([]byte(`
- `), "").IsSvgImage())
+ `)).IsSvgImage())
// the DetectContentType should work for incomplete data, because only beginning bytes are used for detection
- assert.True(t, DetectContentType([]byte(`