Skip to content

Commit a1d61bc

Browse files
jfontanajnavarro
authored andcommitted
gitbase: update go-borges and support old siva files
Supports reading siva files created with borges when using --format siva --non-rooted Signed-off-by: Javi Fontan <[email protected]> Signed-off-by: Antonio Navarro Perez <[email protected]>
1 parent b2762b1 commit a1d61bc

File tree

7 files changed

+43
-24
lines changed

7 files changed

+43
-24
lines changed

cmd/gitbase/command/server.go

+29-12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/sirupsen/logrus"
2121
"github.com/src-d/go-borges"
2222
"github.com/src-d/go-borges/libraries"
23+
"github.com/src-d/go-borges/oldsiva"
2324
"github.com/src-d/go-borges/plain"
2425
"github.com/src-d/go-borges/siva"
2526
sqle "github.com/src-d/go-mysql-server"
@@ -227,7 +228,7 @@ func (c *Server) buildDatabase() error {
227228

228229
c.sharedCache = cache.NewObjectLRU(c.CacheSize * cache.MiByte)
229230

230-
c.rootLibrary = libraries.New(libraries.Options{})
231+
c.rootLibrary = libraries.New(nil)
231232
c.pool = gitbase.NewRepositoryPool(c.sharedCache, c.rootLibrary)
232233

233234
if err := c.addDirectories(); err != nil {
@@ -318,18 +319,34 @@ func (c *Server) addDirectories() error {
318319

319320
func (c *Server) addDirectory(d directory) error {
320321
if d.Format == "siva" {
321-
sivaOpts := siva.LibraryOptions{
322-
Transactional: true,
323-
RootedRepo: d.Rooted,
324-
Cache: c.sharedCache,
325-
Bucket: d.Bucket,
326-
Performance: true,
327-
RegistryCache: 100000,
328-
}
322+
var lib borges.Library
323+
var err error
324+
325+
if d.Rooted {
326+
sivaOpts := &siva.LibraryOptions{
327+
Transactional: true,
328+
RootedRepo: d.Rooted,
329+
Cache: c.sharedCache,
330+
Bucket: d.Bucket,
331+
Performance: true,
332+
RegistryCache: 100000,
333+
}
329334

330-
lib, err := siva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts)
331-
if err != nil {
332-
return err
335+
lib, err = siva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts)
336+
if err != nil {
337+
return err
338+
}
339+
} else {
340+
sivaOpts := &oldsiva.LibraryOptions{
341+
Cache: c.sharedCache,
342+
Bucket: d.Bucket,
343+
RegistryCache: 100000,
344+
}
345+
346+
lib, err = oldsiva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts)
347+
if err != nil {
348+
return err
349+
}
333350
}
334351

335352
err = c.rootLibrary.Add(lib)

common_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,14 @@ func newMultiLibrary() (*multiLibrary, error) {
313313
plainLib.AddLocation(plainLoc)
314314

315315
sivaFS := memfs.New()
316-
sivaLib, err := siva.NewLibrary("siva", sivaFS, siva.LibraryOptions{
316+
sivaLib, err := siva.NewLibrary("siva", sivaFS, &siva.LibraryOptions{
317317
RootedRepo: true,
318318
})
319319
if err != nil {
320320
return nil, err
321321
}
322322

323-
libs := libraries.New(libraries.Options{})
323+
libs := libraries.New(nil)
324324

325325
err = libs.Add(plainLib)
326326
if err != nil {

database_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const testDBName = "foo"
1414
func TestDatabase_Tables(t *testing.T) {
1515
require := require.New(t)
1616

17-
lib := libraries.New(libraries.Options{})
17+
lib := libraries.New(nil)
1818
db := getDB(t, testDBName, NewRepositoryPool(nil, lib))
1919

2020
tables := db.Tables()
@@ -45,7 +45,7 @@ func TestDatabase_Tables(t *testing.T) {
4545
func TestDatabase_Name(t *testing.T) {
4646
require := require.New(t)
4747

48-
lib := libraries.New(libraries.Options{})
48+
lib := libraries.New(nil)
4949
db := getDB(t, testDBName, NewRepositoryPool(nil, lib))
5050
require.Equal(testDBName, db.Name())
5151
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/opentracing/opentracing-go v1.1.0
1515
github.com/sirupsen/logrus v1.3.0
1616
github.com/src-d/enry/v2 v2.0.0
17-
github.com/src-d/go-borges v0.0.0-20190624135448-6ee47472d565
17+
github.com/src-d/go-borges v0.0.0-20190628121335-da12a84d60fd
1818
github.com/src-d/go-git v4.7.0+incompatible
1919
github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible
2020
github.com/src-d/go-mysql-server v0.4.1-0.20190703085445-1538f09dbaaf

go.sum

+4-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ github.com/src-d/enry/v2 v2.0.0 h1:2ADqfDHhroFwL1RGhMS9e15NkEwln8P4AABwVvIdAlo=
217217
github.com/src-d/enry/v2 v2.0.0/go.mod h1:qQeCMRwzMF3ckeGr+h0tJLdxXnq+NVZsIDMELj0t028=
218218
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
219219
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
220-
github.com/src-d/go-borges v0.0.0-20190624135448-6ee47472d565 h1:cyTdUPYEW0oGeXNCjZes3aTr+Ent3F2OHD3rm6Qy/bs=
221-
github.com/src-d/go-borges v0.0.0-20190624135448-6ee47472d565/go.mod h1:Myl/zHrk3iT/I5T08RTBpuGzchucytSsi6p7KzM2lOA=
220+
github.com/src-d/go-borges v0.0.0-20190628121335-da12a84d60fd h1:jUbtZFWSqGX1DfD2evCwA4y7LIrWV0W8h06sjWZANf0=
221+
github.com/src-d/go-borges v0.0.0-20190628121335-da12a84d60fd/go.mod h1:Myl/zHrk3iT/I5T08RTBpuGzchucytSsi6p7KzM2lOA=
222222
github.com/src-d/go-git v4.7.0+incompatible h1:IYSSnbAHeKmsfbQFi9ozbid+KNh0bKjlorMfQehQbcE=
223223
github.com/src-d/go-git v4.7.0+incompatible/go.mod h1:1bQciz+hn0jzPQNsYj0hDFZHLJBdV7gXE2mWhC7EkFk=
224224
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=
379379
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
380380
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
381381
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
382+
honnef.co/go/tools v0.0.0-2019.2.1 h1:fW1wbZIKRbRK56ETe5SYloH5SdLzhXOFet2KlpRKDqg=
383+
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099 h1:XJP7lxbSxWLOMNdBE4B/STaqVy6L73o0knwj2vIlxnw=
382384
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
383385
modernc.org/mathutil v1.0.0 h1:93vKjrJopTPrtTNpZ8XIovER7iCIH1QU7wNbOQXC60I=
384386
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=

integration_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ func TestMissingHeadRefs(t *testing.T) {
748748

749749
path := filepath.Join(cwd, "_testdata")
750750

751-
lib, err := siva.NewLibrary("siva", osfs.New(path), siva.LibraryOptions{
751+
lib, err := siva.NewLibrary("siva", osfs.New(path), &siva.LibraryOptions{
752752
RootedRepo: true,
753753
})
754754
require.NoError(err)

internal/rule/squashjoins_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
func TestAnalyzeSquashJoinsExchange(t *testing.T) {
1919
require := require.New(t)
2020

21-
lib := libraries.New(libraries.Options{})
21+
lib := libraries.New(nil)
2222

2323
catalog := sql.NewCatalog()
2424
catalog.AddDatabase(
@@ -57,7 +57,7 @@ func TestAnalyzeSquashJoinsExchange(t *testing.T) {
5757
func TestAnalyzeSquashNaturalJoins(t *testing.T) {
5858
require := require.New(t)
5959

60-
lib := libraries.New(libraries.Options{})
60+
lib := libraries.New(nil)
6161

6262
catalog := sql.NewCatalog()
6363
catalog.AddDatabase(
@@ -2288,7 +2288,7 @@ func TestIsJoinLeafSquashable(t *testing.T) {
22882288
}
22892289

22902290
func TestOrderedTableNames(t *testing.T) {
2291-
lib := libraries.New(libraries.Options{})
2291+
lib := libraries.New(nil)
22922292
tables := gitbase.NewDatabase("foo", gitbase.NewRepositoryPool(nil, lib)).Tables()
22932293

22942294
input := []sql.Table{
@@ -2830,6 +2830,6 @@ func (l dummyLookup) Indexes() []string {
28302830
}
28312831

28322832
func gitbaseTables() map[string]sql.Table {
2833-
lib := libraries.New(libraries.Options{})
2833+
lib := libraries.New(nil)
28342834
return gitbase.NewDatabase("", gitbase.NewRepositoryPool(nil, lib)).Tables()
28352835
}

0 commit comments

Comments
 (0)