0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-17 15:31:06 +01:00

Re-enable import local paths after reversion from #13610 (#14925)

PR #13610 unfortunately disabled importing repositories from local paths.
This PR restores this functionality.

Fix #14700

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath 2021-03-08 13:10:17 +00:00 committed by GitHub
parent c03f530212
commit eb576269d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -52,6 +52,13 @@ func isMigrateURLAllowed(remoteURL string) error {
} }
} }
if u.Host == "" {
if !setting.ImportLocalPaths {
return &models.ErrMigrationNotAllowed{Host: "<LOCAL_FILESYSTEM>"}
}
return nil
}
if !setting.Migrations.AllowLocalNetworks { if !setting.Migrations.AllowLocalNetworks {
addrList, err := net.LookupIP(strings.Split(u.Host, ":")[0]) addrList, err := net.LookupIP(strings.Split(u.Host, ":")[0])
if err != nil { if err != nil {

View file

@ -31,4 +31,16 @@ func TestMigrateWhiteBlocklist(t *testing.T) {
err = isMigrateURLAllowed("https://github.com/go-gitea/gitea.git") err = isMigrateURLAllowed("https://github.com/go-gitea/gitea.git")
assert.Error(t, err) assert.Error(t, err)
old := setting.ImportLocalPaths
setting.ImportLocalPaths = false
err = isMigrateURLAllowed("/home/foo/bar/goo")
assert.Error(t, err)
setting.ImportLocalPaths = true
err = isMigrateURLAllowed("/home/foo/bar/goo")
assert.NoError(t, err)
setting.ImportLocalPaths = old
} }