diff --git a/CHANGELOG.md b/CHANGELOG.md index b4be8643f..c5c09e615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Now non rooted siva files support old siva rooted repositories. + ## [0.22.0] - 2019-07-03 ### Added diff --git a/cmd/gitbase/command/server.go b/cmd/gitbase/command/server.go index d9ebbace3..b49996b38 100644 --- a/cmd/gitbase/command/server.go +++ b/cmd/gitbase/command/server.go @@ -20,6 +20,7 @@ import ( "github.com/sirupsen/logrus" "github.com/src-d/go-borges" "github.com/src-d/go-borges/libraries" + "github.com/src-d/go-borges/oldsiva" "github.com/src-d/go-borges/plain" "github.com/src-d/go-borges/siva" sqle "github.com/src-d/go-mysql-server" @@ -227,7 +228,7 @@ func (c *Server) buildDatabase() error { c.sharedCache = cache.NewObjectLRU(c.CacheSize * cache.MiByte) - c.rootLibrary = libraries.New(libraries.Options{}) + c.rootLibrary = libraries.New(nil) c.pool = gitbase.NewRepositoryPool(c.sharedCache, c.rootLibrary) if err := c.addDirectories(); err != nil { @@ -318,18 +319,34 @@ func (c *Server) addDirectories() error { func (c *Server) addDirectory(d directory) error { if d.Format == "siva" { - sivaOpts := siva.LibraryOptions{ - Transactional: true, - RootedRepo: d.Rooted, - Cache: c.sharedCache, - Bucket: d.Bucket, - Performance: true, - RegistryCache: 100000, - } + var lib borges.Library + var err error + + if d.Rooted { + sivaOpts := &siva.LibraryOptions{ + Transactional: true, + RootedRepo: d.Rooted, + Cache: c.sharedCache, + Bucket: d.Bucket, + Performance: true, + RegistryCache: 100000, + } - lib, err := siva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts) - if err != nil { - return err + lib, err = siva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts) + if err != nil { + return err + } + } else { + sivaOpts := &oldsiva.LibraryOptions{ + Cache: c.sharedCache, + Bucket: d.Bucket, + RegistryCache: 100000, + } + + lib, err = oldsiva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts) + if err != nil { + return err + } } err = c.rootLibrary.Add(lib) diff --git a/common_test.go b/common_test.go index e2b13a887..d9aa34b30 100644 --- a/common_test.go +++ b/common_test.go @@ -313,14 +313,14 @@ func newMultiLibrary() (*multiLibrary, error) { plainLib.AddLocation(plainLoc) sivaFS := memfs.New() - sivaLib, err := siva.NewLibrary("siva", sivaFS, siva.LibraryOptions{ + sivaLib, err := siva.NewLibrary("siva", sivaFS, &siva.LibraryOptions{ RootedRepo: true, }) if err != nil { return nil, err } - libs := libraries.New(libraries.Options{}) + libs := libraries.New(nil) err = libs.Add(plainLib) if err != nil { diff --git a/database_test.go b/database_test.go index 61681a3f1..4bb15f00f 100644 --- a/database_test.go +++ b/database_test.go @@ -14,7 +14,7 @@ const testDBName = "foo" func TestDatabase_Tables(t *testing.T) { require := require.New(t) - lib := libraries.New(libraries.Options{}) + lib := libraries.New(nil) db := getDB(t, testDBName, NewRepositoryPool(nil, lib)) tables := db.Tables() @@ -45,7 +45,7 @@ func TestDatabase_Tables(t *testing.T) { func TestDatabase_Name(t *testing.T) { require := require.New(t) - lib := libraries.New(libraries.Options{}) + lib := libraries.New(nil) db := getDB(t, testDBName, NewRepositoryPool(nil, lib)) require.Equal(testDBName, db.Name()) } diff --git a/go.mod b/go.mod index 7472f3ad9..922f052ac 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/opentracing/opentracing-go v1.1.0 github.com/sirupsen/logrus v1.3.0 github.com/src-d/enry/v2 v2.0.0 - github.com/src-d/go-borges v0.0.0-20190624135448-6ee47472d565 + github.com/src-d/go-borges v0.0.0-20190628121335-da12a84d60fd github.com/src-d/go-git v4.7.0+incompatible github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible github.com/src-d/go-mysql-server v0.4.1-0.20190703085445-1538f09dbaaf diff --git a/go.sum b/go.sum index 8c45d0813..0b57e219f 100644 --- a/go.sum +++ b/go.sum @@ -217,8 +217,8 @@ github.com/src-d/enry/v2 v2.0.0 h1:2ADqfDHhroFwL1RGhMS9e15NkEwln8P4AABwVvIdAlo= github.com/src-d/enry/v2 v2.0.0/go.mod h1:qQeCMRwzMF3ckeGr+h0tJLdxXnq+NVZsIDMELj0t028= github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4= github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= -github.com/src-d/go-borges v0.0.0-20190624135448-6ee47472d565 h1:cyTdUPYEW0oGeXNCjZes3aTr+Ent3F2OHD3rm6Qy/bs= -github.com/src-d/go-borges v0.0.0-20190624135448-6ee47472d565/go.mod h1:Myl/zHrk3iT/I5T08RTBpuGzchucytSsi6p7KzM2lOA= +github.com/src-d/go-borges v0.0.0-20190628121335-da12a84d60fd h1:jUbtZFWSqGX1DfD2evCwA4y7LIrWV0W8h06sjWZANf0= +github.com/src-d/go-borges v0.0.0-20190628121335-da12a84d60fd/go.mod h1:Myl/zHrk3iT/I5T08RTBpuGzchucytSsi6p7KzM2lOA= github.com/src-d/go-git v4.7.0+incompatible h1:IYSSnbAHeKmsfbQFi9ozbid+KNh0bKjlorMfQehQbcE= github.com/src-d/go-git v4.7.0+incompatible/go.mod h1:1bQciz+hn0jzPQNsYj0hDFZHLJBdV7gXE2mWhC7EkFk= github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible h1:A5bKevhs9C//Nh8QV0J+1KphEaIa25cDe1DTs/yPxDI= @@ -379,6 +379,8 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.0-2019.2.1 h1:fW1wbZIKRbRK56ETe5SYloH5SdLzhXOFet2KlpRKDqg= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099 h1:XJP7lxbSxWLOMNdBE4B/STaqVy6L73o0knwj2vIlxnw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= modernc.org/mathutil v1.0.0 h1:93vKjrJopTPrtTNpZ8XIovER7iCIH1QU7wNbOQXC60I= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/integration_test.go b/integration_test.go index f763296ee..6c2d44b57 100644 --- a/integration_test.go +++ b/integration_test.go @@ -748,7 +748,7 @@ func TestMissingHeadRefs(t *testing.T) { path := filepath.Join(cwd, "_testdata") - lib, err := siva.NewLibrary("siva", osfs.New(path), siva.LibraryOptions{ + lib, err := siva.NewLibrary("siva", osfs.New(path), &siva.LibraryOptions{ RootedRepo: true, }) require.NoError(err) diff --git a/internal/rule/squashjoins_test.go b/internal/rule/squashjoins_test.go index 7856b3ef0..8801f4c48 100644 --- a/internal/rule/squashjoins_test.go +++ b/internal/rule/squashjoins_test.go @@ -18,7 +18,7 @@ import ( func TestAnalyzeSquashJoinsExchange(t *testing.T) { require := require.New(t) - lib := libraries.New(libraries.Options{}) + lib := libraries.New(nil) catalog := sql.NewCatalog() catalog.AddDatabase( @@ -57,7 +57,7 @@ func TestAnalyzeSquashJoinsExchange(t *testing.T) { func TestAnalyzeSquashNaturalJoins(t *testing.T) { require := require.New(t) - lib := libraries.New(libraries.Options{}) + lib := libraries.New(nil) catalog := sql.NewCatalog() catalog.AddDatabase( @@ -2288,7 +2288,7 @@ func TestIsJoinLeafSquashable(t *testing.T) { } func TestOrderedTableNames(t *testing.T) { - lib := libraries.New(libraries.Options{}) + lib := libraries.New(nil) tables := gitbase.NewDatabase("foo", gitbase.NewRepositoryPool(nil, lib)).Tables() input := []sql.Table{ @@ -2830,6 +2830,6 @@ func (l dummyLookup) Indexes() []string { } func gitbaseTables() map[string]sql.Table { - lib := libraries.New(libraries.Options{}) + lib := libraries.New(nil) return gitbase.NewDatabase("", gitbase.NewRepositoryPool(nil, lib)).Tables() }