]> source.dussan.org Git - gitea.git/commitdiff
Re-enable import local paths after reversion from #13610 (#14925)
authorzeripath <art27@cantab.net>
Mon, 8 Mar 2021 13:10:17 +0000 (13:10 +0000)
committerGitHub <noreply@github.com>
Mon, 8 Mar 2021 13:10:17 +0000 (13:10 +0000)
PR #13610 unfortunately disabled importing repositories from local paths.
This PR restores this functionality.

Fix #14700

Signed-off-by: Andrew Thornton <art27@cantab.net>
modules/migrations/migrate.go
modules/migrations/migrate_test.go

index b9c17478a9982b55a6e1b9f703cfd94c255cce3a..656b78a584895f6462563786bfbb4381fd73e036 100644 (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 {
                addrList, err := net.LookupIP(strings.Split(u.Host, ":")[0])
                if err != nil {
index 3bad5cfd736be14b69f5b1a113d43390db8ac1ec..e8b71bb325bfc692b7f6bf75524c5b204d0e26c4 100644 (file)
@@ -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
 }