mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-21 11:51:54 +02:00
chore: update golangci-lint to v2.13.0
Migrate the deprecated gofumpt `extra-rules` to `extra.group-params`, as the alias now also enables the new `clothe-returns` and `balance-calls` rules. Disable SA4023, which hangs on go 1.27, see https://github.com/golangci/golangci-lint/issues/6732. Apply the resulting modernize fixes, mostly flattening embedded struct literals and switching errors.As to errors.AsType. Assisted-by: Claude:Opus 5
This commit is contained in:
@@ -29,13 +29,11 @@ func registerUpdateMirrorTask() {
|
||||
}
|
||||
|
||||
RegisterTaskFatal("update_mirrors", &UpdateMirrorTaskConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 10m",
|
||||
},
|
||||
PullLimit: 50,
|
||||
PushLimit: 50,
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 10m",
|
||||
PullLimit: 50,
|
||||
PushLimit: 50,
|
||||
}, func(ctx context.Context, _ *user_model.User, cfg *UpdateMirrorTaskConfig) error {
|
||||
return mirror_service.Update(ctx, cfg.PullLimit, cfg.PushLimit)
|
||||
})
|
||||
@@ -48,13 +46,11 @@ func registerRepoHealthCheck() {
|
||||
Args []string `delim:" "`
|
||||
}
|
||||
RegisterTaskFatal("repo_health_check", &RepoHealthCheckConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@midnight",
|
||||
},
|
||||
Timeout: time.Duration(setting.Git.Timeout.GC) * time.Second,
|
||||
Args: []string{},
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@midnight",
|
||||
Timeout: time.Duration(setting.Git.Timeout.GC) * time.Second,
|
||||
Args: []string{},
|
||||
}, func(ctx context.Context, _ *user_model.User, config *RepoHealthCheckConfig) error {
|
||||
// the git args are set by config, they can be safe to be trusted
|
||||
return repo_service.GitFsckRepos(ctx, config.Timeout, gitcmd.ToTrustedCmdArgs(config.Args))
|
||||
@@ -73,12 +69,10 @@ func registerCheckRepoStats() {
|
||||
|
||||
func registerArchiveCleanup() {
|
||||
RegisterTaskFatal("archive_cleanup", &OlderThanConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: true,
|
||||
Schedule: "@midnight",
|
||||
},
|
||||
OlderThan: 24 * time.Hour,
|
||||
Enabled: true,
|
||||
RunAtStart: true,
|
||||
Schedule: "@midnight",
|
||||
OlderThan: 24 * time.Hour,
|
||||
}, func(ctx context.Context, _ *user_model.User, config *OlderThanConfig) error {
|
||||
return archiver_service.DeleteOldRepositoryArchives(ctx, config.OlderThan)
|
||||
})
|
||||
@@ -86,11 +80,9 @@ func registerArchiveCleanup() {
|
||||
|
||||
func registerSyncExternalUsers() {
|
||||
RegisterTaskFatal("sync_external_users", &UpdateExistingConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@midnight",
|
||||
},
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@midnight",
|
||||
UpdateExisting: true,
|
||||
}, func(ctx context.Context, _ *user_model.User, config *UpdateExistingConfig) error {
|
||||
return auth.SyncExternalUsers(ctx, config.UpdateExisting)
|
||||
@@ -99,12 +91,10 @@ func registerSyncExternalUsers() {
|
||||
|
||||
func registerDeletedBranchesCleanup() {
|
||||
RegisterTaskFatal("deleted_branches_cleanup", &OlderThanConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: true,
|
||||
Schedule: "@midnight",
|
||||
},
|
||||
OlderThan: 24 * time.Hour,
|
||||
Enabled: true,
|
||||
RunAtStart: true,
|
||||
Schedule: "@midnight",
|
||||
OlderThan: 24 * time.Hour,
|
||||
}, func(ctx context.Context, _ *user_model.User, config *OlderThanConfig) error {
|
||||
git_model.RemoveOldDeletedBranches(ctx, config.OlderThan)
|
||||
return nil
|
||||
@@ -123,11 +113,9 @@ func registerUpdateMigrationPosterID() {
|
||||
|
||||
func registerCleanupHookTaskTable() {
|
||||
RegisterTaskFatal("cleanup_hook_task_table", &CleanupHookTaskConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@midnight",
|
||||
},
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@midnight",
|
||||
CleanupType: "OlderThan",
|
||||
OlderThan: 168 * time.Hour,
|
||||
NumberToKeep: 10,
|
||||
@@ -138,12 +126,10 @@ func registerCleanupHookTaskTable() {
|
||||
|
||||
func registerCleanupPackages() {
|
||||
RegisterTaskFatal("cleanup_packages", &OlderThanConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: true,
|
||||
Schedule: "@midnight",
|
||||
},
|
||||
OlderThan: 24 * time.Hour,
|
||||
Enabled: true,
|
||||
RunAtStart: true,
|
||||
Schedule: "@midnight",
|
||||
OlderThan: 24 * time.Hour,
|
||||
}, func(ctx context.Context, _ *user_model.User, config *OlderThanConfig) error {
|
||||
return packages_cleanup_service.CleanupTask(ctx, config.OlderThan)
|
||||
})
|
||||
|
||||
@@ -22,12 +22,10 @@ import (
|
||||
|
||||
func registerDeleteInactiveUsers() {
|
||||
RegisterTaskFatal("delete_inactive_accounts", &OlderThanConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@annually",
|
||||
},
|
||||
OlderThan: time.Minute * time.Duration(setting.Service.ActiveCodeLives),
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@annually",
|
||||
OlderThan: time.Minute * time.Duration(setting.Service.ActiveCodeLives),
|
||||
}, func(ctx context.Context, _ *user_model.User, config *OlderThanConfig) error {
|
||||
return user_service.DeleteInactiveUsers(ctx, config.OlderThan)
|
||||
})
|
||||
@@ -50,13 +48,11 @@ func registerGarbageCollectRepositories() {
|
||||
Args []string `delim:" "`
|
||||
}
|
||||
RegisterTaskFatal("git_gc_repos", &RepoHealthCheckConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 72h",
|
||||
},
|
||||
Timeout: time.Duration(setting.Git.Timeout.GC) * time.Second,
|
||||
Args: setting.Git.GCArgs,
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 72h",
|
||||
Timeout: time.Duration(setting.Git.Timeout.GC) * time.Second,
|
||||
Args: setting.Git.GCArgs,
|
||||
}, func(ctx context.Context, _ *user_model.User, config *RepoHealthCheckConfig) error {
|
||||
// the git args are set by config, they can be safe to be trusted
|
||||
return repo_service.GitGcRepos(ctx, config.Timeout, gitcmd.ToTrustedCmdArgs(config.Args))
|
||||
@@ -125,12 +121,10 @@ func registerRemoveRandomAvatars() {
|
||||
|
||||
func registerDeleteOldActions() {
|
||||
RegisterTaskFatal("delete_old_actions", &OlderThanConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 168h",
|
||||
},
|
||||
OlderThan: 365 * 24 * time.Hour,
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 168h",
|
||||
OlderThan: 365 * 24 * time.Hour,
|
||||
}, func(ctx context.Context, _ *user_model.User, config *OlderThanConfig) error {
|
||||
return activities_model.DeleteOldActions(ctx, config.OlderThan)
|
||||
})
|
||||
@@ -142,11 +136,9 @@ func registerUpdateGiteaChecker() {
|
||||
HTTPEndpoint string
|
||||
}
|
||||
RegisterTaskFatal("update_checker", &UpdateCheckerConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 168h",
|
||||
},
|
||||
Enabled: true,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 168h",
|
||||
HTTPEndpoint: "https://dl.gitea.com/gitea/version.json",
|
||||
}, func(ctx context.Context, _ *user_model.User, config *UpdateCheckerConfig) error {
|
||||
return updatechecker.GiteaUpdateChecker(config.HTTPEndpoint)
|
||||
@@ -155,12 +147,10 @@ func registerUpdateGiteaChecker() {
|
||||
|
||||
func registerDeleteOldSystemNotices() {
|
||||
RegisterTaskFatal("delete_old_system_notices", &OlderThanConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 168h",
|
||||
},
|
||||
OlderThan: 365 * 24 * time.Hour,
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 168h",
|
||||
OlderThan: 365 * 24 * time.Hour,
|
||||
}, func(ctx context.Context, _ *user_model.User, config *OlderThanConfig) error {
|
||||
return system.DeleteOldSystemNotices(ctx, config.OlderThan)
|
||||
})
|
||||
@@ -180,11 +170,9 @@ func registerGCLFS() {
|
||||
}
|
||||
|
||||
RegisterTaskFatal("gc_lfs", &GCLFSConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 24h",
|
||||
},
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 24h",
|
||||
// Only attempt to garbage collect lfs meta objects older than a week as the order of git lfs upload
|
||||
// and git object upload is not necessarily guaranteed. It's possible to imagine a situation whereby
|
||||
// an LFS object is uploaded but the git branch is not uploaded immediately, or there are some rapid
|
||||
|
||||
@@ -28,11 +28,9 @@ PROPORTION_TO_CHECK_PER_REPO = 0.1
|
||||
defer test.MockVariableValue(&setting.CfgProvider, cfg)()
|
||||
|
||||
config := &GCLFSConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 24h",
|
||||
},
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@every 24h",
|
||||
OlderThan: 24 * time.Hour * 7,
|
||||
LastUpdatedMoreThanAgo: 24 * time.Hour * 3,
|
||||
NumberToCheckPerRepo: 100,
|
||||
|
||||
Reference in New Issue
Block a user