summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-03-08 13:10:17 +0000
committerGitHub <noreply@github.com>2021-03-08 13:10:17 +0000
commiteb576269d4fe83684c6946c2fa65038391362075 (patch)
tree3956e28ae26d141da7c5e9a588392dd1b45aecfa
parentc03f530212249b18ffb73dfa47c99e9a4ed7c86c (diff)
downloadgitea-eb576269d4fe83684c6946c2fa65038391362075.tar.gz
gitea-eb576269d4fe83684c6946c2fa65038391362075.zip
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>
-rw-r--r--modules/migrations/migrate.go7
-rw-r--r--modules/migrations/migrate_test.go12
2 files changed, 19 insertions, 0 deletions
diff --git a/modules/migrations/migrate.go b/modules/migrations/migrate.go
index b9c17478a9..656b78a584 100644
--- a/modules/migrations/migrate.go
+++ b/modules/migrations/migrate.go
@@ -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 {
addrList, err := net.LookupIP(strings.Split(u.Host, ":")[0])
if err != nil {
diff --git a/modules/migrations/migrate_test.go b/modules/migrations/migrate_test.go
index 3bad5cfd73..e8b71bb325 100644
--- a/modules/migrations/migrate_test.go
+++ b/modules/migrations/migrate_test.go
@@ -31,4 +31,16 @@ func TestMigrateWhiteBlocklist(t *testing.T) {
err = isMigrateURLAllowed("https://github.com/go-gitea/gitea.git")
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
}