mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 01:34:27 +00:00 
			
		
		
		
	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:
		@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user