Skip to content

Commit 74ed6dc

Browse files
Bwkolunny
authored andcommitted
Add option to app.ini to enable local import paths (#724)
1 parent 1257d43 commit 74ed6dc

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

conf/app.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ COOKIE_REMEMBER_NAME = gitea_incredible
173173
REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER
174174
; Sets the minimum password length for new Users
175175
MIN_PASSWORD_LENGTH = 6
176+
; True when users are allowed to import local server paths
177+
IMPORT_LOCAL_PATHS = false
176178

177179
[service]
178180
ACTIVE_CODE_LIVE_MINUTES = 180

models/user.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ func (u *User) CanEditGitHook() bool {
233233

234234
// CanImportLocal returns true if user can migrate repository by local path.
235235
func (u *User) CanImportLocal() bool {
236+
if !setting.ImportLocalPaths {
237+
return false
238+
}
236239
return u.IsAdmin || u.AllowImportLocal
237240
}
238241

modules/setting/setting.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ var (
114114
CookieRememberName string
115115
ReverseProxyAuthUser string
116116
MinPasswordLength int
117+
ImportLocalPaths bool
117118

118119
// Database settings
119120
UseSQLite3 bool
@@ -712,6 +713,7 @@ please consider changing to GITEA_CUSTOM`)
712713
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
713714
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
714715
MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
716+
ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
715717

716718
sec = Cfg.Section("attachment")
717719
AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
@@ -897,11 +899,11 @@ func newLogService() {
897899

898900
useConsole := false
899901
for _, mode := range LogModes {
900-
if mode == "console" {
902+
if mode == "console" {
901903
useConsole = true
902904
}
903905
}
904-
if (!useConsole) {
906+
if !useConsole {
905907
log.DelLogger("console")
906908
}
907909

options/locale/locale_en-US.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ migrate_type = Migration Type
425425
migrate_type_helper = This repository will be a <span class="text blue">mirror</span>
426426
migrate_repo = Migrate Repository
427427
migrate.clone_address = Clone Address
428-
migrate.clone_address_desc = This can be a HTTP/HTTPS/GIT URL or local server path.
428+
migrate.clone_address_desc = This can be a HTTP/HTTPS/GIT URL
429+
migrate.clone_local_path = or local server path
429430
migrate.permission_denied = You are not allowed to import local repositories.
430431
migrate.invalid_local_path = Invalid local path, it does not exist or not a directory.
431432
migrate.failed = Migration failed: %v

options/locale/locale_nl-NL.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ migrate_type=Migratie type
384384
migrate_type_helper=Deze repository zal een <span class="text blue">kopie</span> zijn
385385
migrate_repo=Migreer repository
386386
migrate.clone_address=Kloon adres
387-
migrate.clone_address_desc=Dit kan een HTTP/HTTPS/GIT URL zijn of een lokaal pad.
387+
migrate.clone_address_desc=Dit kan een HTTP/HTTPS/GIT URL zijn
388+
migrate.clone_local_path =of een lokaal pad
388389
migrate.permission_denied=U bent niet gemachtigd om deze lokale repositories te importeren.
389390
migrate.invalid_local_path=Ongeldig lokaal pad, het pad bestaat niet of het is geen map.
390391
migrate.failed=Migratie is mislukt: %v

templates/repo/migrate.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="inline required field {{if .Err_CloneAddr}}error{{end}}">
1313
<label for="clone_addr">{{.i18n.Tr "repo.migrate.clone_address"}}</label>
1414
<input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required>
15-
<span class="help">{{.i18n.Tr "repo.migrate.clone_address_desc"}}</span>
15+
<span class="help">{{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}}</span>
1616
</div>
1717
<div class="ui accordion optional field">
1818
<div class="title {{if .Err_Auth}}text red active{{end}}">

0 commit comments

Comments
 (0)