Added option to disable migrations (#13114)
* Added option to disable migrations This patch introduces DISABLE_MIGRATIONS parameter in [repository] section of app.ini (by default set to false). If set to true it blocks access to repository migration feature. This mod hides also local repo import option in user editor if local repo importing or migrations is disabled. * Alter Example config DISABLE_MIGRATIONS set to false in example config to match its default value. * HTTP error 403 instead of 500 on denied access to migration * Parameter DISABLE_MIGRATIONS exposed via API Fixes: 04b04cf854bcb3ed7659442bcf79822bdebe29e9 Author-Change-Id: IB#1105130
This commit is contained in:
parent
3a500cf8c4
commit
839daa85aa
14 changed files with 52 additions and 11 deletions
|
@ -343,6 +343,7 @@ func Contexter() macaron.Handler {
|
|||
|
||||
ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
|
||||
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
|
||||
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
|
||||
|
||||
c.Map(ctx)
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/migrations"
|
||||
repository_service "code.gitea.io/gitea/modules/repository"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
mirror_service "code.gitea.io/gitea/services/mirror"
|
||||
)
|
||||
|
||||
|
@ -115,5 +116,7 @@ func initBasicTasks() {
|
|||
registerArchiveCleanup()
|
||||
registerSyncExternalUsers()
|
||||
registerDeletedBranchesCleanup()
|
||||
registerUpdateMigrationPosterID()
|
||||
if !setting.Repository.DisableMigrations {
|
||||
registerUpdateMigrationPosterID()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ var (
|
|||
DefaultRepoUnits []string
|
||||
PrefixArchiveFiles bool
|
||||
DisableMirrors bool
|
||||
DisableMigrations bool
|
||||
DefaultBranch string
|
||||
AllowAdoptionOfUnadoptedRepositories bool
|
||||
AllowDeleteOfUnadoptedRepositories bool
|
||||
|
@ -152,6 +153,7 @@ var (
|
|||
DefaultRepoUnits: []string{},
|
||||
PrefixArchiveFiles: true,
|
||||
DisableMirrors: false,
|
||||
DisableMigrations: false,
|
||||
DefaultBranch: "master",
|
||||
|
||||
// Repository editor settings
|
||||
|
|
|
@ -6,8 +6,9 @@ package structs
|
|||
|
||||
// GeneralRepoSettings contains global repository settings exposed by API
|
||||
type GeneralRepoSettings struct {
|
||||
MirrorsDisabled bool `json:"mirrors_disabled"`
|
||||
HTTPGitDisabled bool `json:"http_git_disabled"`
|
||||
MirrorsDisabled bool `json:"mirrors_disabled"`
|
||||
HTTPGitDisabled bool `json:"http_git_disabled"`
|
||||
MigrationsDisabled bool `json:"migrations_disabled"`
|
||||
}
|
||||
|
||||
// GeneralUISettings contains global ui settings exposed by API
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue