Skip to content

Commit 906ecfd

Browse files
authored
Re-enable import local paths after reversion from #13610 (#14925) (#14927)
Backport #14925 PR #13610 unfortunately disabled importing repositories from local paths. This PR restores this functionality. Fix #14700 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 75496b9 commit 906ecfd

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

modules/migrations/migrate.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ func isMigrateURLAllowed(remoteURL string) error {
5252
}
5353
}
5454

55+
if u.Host == "" {
56+
if !setting.ImportLocalPaths {
57+
return &models.ErrMigrationNotAllowed{Host: "<LOCAL_FILESYSTEM>"}
58+
}
59+
return nil
60+
}
61+
5562
if !setting.Migrations.AllowLocalNetworks {
5663
addrList, err := net.LookupIP(strings.Split(u.Host, ":")[0])
5764
if err != nil {

modules/migrations/migrate_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,16 @@ func TestMigrateWhiteBlocklist(t *testing.T) {
3131

3232
err = isMigrateURLAllowed("https://github.com/go-gitea/gitea.git")
3333
assert.Error(t, err)
34+
35+
old := setting.ImportLocalPaths
36+
setting.ImportLocalPaths = false
37+
38+
err = isMigrateURLAllowed("/home/foo/bar/goo")
39+
assert.Error(t, err)
40+
41+
setting.ImportLocalPaths = true
42+
err = isMigrateURLAllowed("/home/foo/bar/goo")
43+
assert.NoError(t, err)
44+
45+
setting.ImportLocalPaths = old
3446
}

0 commit comments

Comments
 (0)