From 74ed6dc3ad830d308a032fe213e9dfe83f954ffc Mon Sep 17 00:00:00 2001 From: Bwko Date: Mon, 23 Jan 2017 02:19:50 +0100 Subject: [PATCH] Add option to app.ini to enable local import paths (#724) --- conf/app.ini | 2 ++ models/user.go | 3 +++ modules/setting/setting.go | 6 ++++-- options/locale/locale_en-US.ini | 3 ++- options/locale/locale_nl-NL.ini | 3 ++- templates/repo/migrate.tmpl | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index ec4a3e303..303b006b2 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -173,6 +173,8 @@ COOKIE_REMEMBER_NAME = gitea_incredible REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER ; Sets the minimum password length for new Users MIN_PASSWORD_LENGTH = 6 +; True when users are allowed to import local server paths +IMPORT_LOCAL_PATHS = false [service] ACTIVE_CODE_LIVE_MINUTES = 180 diff --git a/models/user.go b/models/user.go index 86573dbda..306b695bf 100644 --- a/models/user.go +++ b/models/user.go @@ -233,6 +233,9 @@ func (u *User) CanEditGitHook() bool { // CanImportLocal returns true if user can migrate repository by local path. func (u *User) CanImportLocal() bool { + if !setting.ImportLocalPaths { + return false + } return u.IsAdmin || u.AllowImportLocal } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 16177e889..c07b584b8 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -114,6 +114,7 @@ var ( CookieRememberName string ReverseProxyAuthUser string MinPasswordLength int + ImportLocalPaths bool // Database settings UseSQLite3 bool @@ -712,6 +713,7 @@ please consider changing to GITEA_CUSTOM`) CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible") ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER") MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6) + ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false) sec = Cfg.Section("attachment") AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments")) @@ -897,11 +899,11 @@ func newLogService() { useConsole := false for _, mode := range LogModes { - if mode == "console" { + if mode == "console" { useConsole = true } } - if (!useConsole) { + if !useConsole { log.DelLogger("console") } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 9b9e25ba8..7689a85c5 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -425,7 +425,8 @@ migrate_type = Migration Type migrate_type_helper = This repository will be a mirror migrate_repo = Migrate Repository migrate.clone_address = Clone Address -migrate.clone_address_desc = This can be a HTTP/HTTPS/GIT URL or local server path. +migrate.clone_address_desc = This can be a HTTP/HTTPS/GIT URL +migrate.clone_local_path = or local server path migrate.permission_denied = You are not allowed to import local repositories. migrate.invalid_local_path = Invalid local path, it does not exist or not a directory. migrate.failed = Migration failed: %v diff --git a/options/locale/locale_nl-NL.ini b/options/locale/locale_nl-NL.ini index 0193555bf..e80ea6cb4 100644 --- a/options/locale/locale_nl-NL.ini +++ b/options/locale/locale_nl-NL.ini @@ -384,7 +384,8 @@ migrate_type=Migratie type migrate_type_helper=Deze repository zal een kopie zijn migrate_repo=Migreer repository migrate.clone_address=Kloon adres -migrate.clone_address_desc=Dit kan een HTTP/HTTPS/GIT URL zijn of een lokaal pad. +migrate.clone_address_desc=Dit kan een HTTP/HTTPS/GIT URL zijn +migrate.clone_local_path =of een lokaal pad migrate.permission_denied=U bent niet gemachtigd om deze lokale repositories te importeren. migrate.invalid_local_path=Ongeldig lokaal pad, het pad bestaat niet of het is geen map. migrate.failed=Migratie is mislukt: %v diff --git a/templates/repo/migrate.tmpl b/templates/repo/migrate.tmpl index 2ac391527..17d563032 100644 --- a/templates/repo/migrate.tmpl +++ b/templates/repo/migrate.tmpl @@ -12,7 +12,7 @@
- {{.i18n.Tr "repo.migrate.clone_address_desc"}} + {{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}}