Skip to content

Commit

Permalink
*: upgrade go-borges to support metadata reload
Browse files Browse the repository at this point in the history
* this versions supports reloading library metadata
* if a siva library is found without metadata a new one is generated
(library.yaml)
* oldsiva was renamed to legacysiva
* plain libraries now accept options

Signed-off-by: Javi Fontan <[email protected]>
  • Loading branch information
jfontan committed Aug 23, 2019
1 parent cc6a9b4 commit 145e71f
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- `go-borges` library was updated to `0.1.1` to support metadata reloading.

## [0.24.0-beta3] - 2019-07-31

### Added
Expand Down
2 changes: 2 additions & 0 deletions _testdata/library.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: d4213320-c4f0-11e9-b018-9cb6d0e2bf3b
version: -1
10 changes: 5 additions & 5 deletions cmd/gitbase/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/opentracing/opentracing-go"
"github.com/sirupsen/logrus"
"github.com/src-d/go-borges"
"github.com/src-d/go-borges/legacysiva"
"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"
Expand Down Expand Up @@ -360,18 +360,18 @@ func (c *Server) addDirectory(d directory) error {
RegistryCache: 100000,
}

lib, err = siva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts)
lib, err = siva.NewLibrary("", osfs.New(d.Path), sivaOpts)
if err != nil {
return err
}
} else {
sivaOpts := &oldsiva.LibraryOptions{
sivaOpts := &legacysiva.LibraryOptions{
Cache: c.sharedCache,
Bucket: d.Bucket,
RegistryCache: 100000,
}

lib, err = oldsiva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts)
lib, err = legacysiva.NewLibrary(d.Path, osfs.New(d.Path), sivaOpts)
if err != nil {
return err
}
Expand All @@ -397,7 +397,7 @@ func (c *Server) addDirectory(d directory) error {
}

if c.plainLibrary == nil {
c.plainLibrary = plain.NewLibrary(borges.LibraryID("plain"))
c.plainLibrary = plain.NewLibrary(borges.LibraryID("plain"), nil)
err := c.rootLibrary.Add(c.plainLibrary)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ func newMultiLibrary() (*multiLibrary, error) {
if err != nil {
return nil, err
}
plainLib := plain.NewLibrary("plain")
plainLib := plain.NewLibrary("plain", nil)
plainLib.AddLocation(plainLoc)

sivaFS := memfs.New()
sivaLib, err := siva.NewLibrary("siva", sivaFS, &siva.LibraryOptions{
sivaLib, err := siva.NewLibrary("", sivaFS, &siva.LibraryOptions{
RootedRepo: true,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/prometheus/client_golang v1.0.0
github.com/sirupsen/logrus v1.4.2
github.com/src-d/enry/v2 v2.0.0
github.com/src-d/go-borges v0.0.0-20190628121335-da12a84d60fd
github.com/src-d/go-borges v0.1.1
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.20190821121850-0e0249cf7bc0
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-github v15.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/handlers v1.3.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA=
github.com/gorilla/handlers v1.4.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
Expand Down Expand Up @@ -239,8 +241,8 @@ github.com/src-d/enry/v2 v2.0.0/go.mod h1:qQeCMRwzMF3ckeGr+h0tJLdxXnq+NVZsIDMELj
github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc=
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-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-borges v0.1.1 h1:URkX6ycDzodt5n6mAF54cdjmmAMSWIyuL12ga/E5/sM=
github.com/src-d/go-borges v0.1.1/go.mod h1:q/ufK0FXUS0ngH1Crd1TyirdtUM4dl/5ky2Oxiaw4YA=
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=
Expand Down
12 changes: 6 additions & 6 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"testing"
"time"

"github.com/src-d/gitbase"
"github.com/src-d/gitbase/cmd/gitbase/command"
"github.com/src-d/gitbase/internal/function"
"github.com/src-d/gitbase/internal/rule"

"github.com/src-d/go-borges/plain"
"github.com/src-d/go-borges/siva"

"github.com/src-d/gitbase"
"github.com/src-d/gitbase/internal/function"
fixtures "github.com/src-d/go-git-fixtures"
sqle "github.com/src-d/go-mysql-server"
"github.com/src-d/go-mysql-server/auth"
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestIntegration(t *testing.T) {
err = os.Rename(path, pathRepo)
require.NoError(t, err)

lib := plain.NewLibrary("plain")
lib := plain.NewLibrary("plain", nil)
loc, err := plain.NewLocation("location", osfs.New(pathLib), nil)
require.NoError(t, err)
lib.AddLocation(loc)
Expand Down Expand Up @@ -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("", osfs.New(path), &siva.LibraryOptions{
RootedRepo: true,
})
require.NoError(err)
Expand Down Expand Up @@ -1122,7 +1122,7 @@ func setup(t testing.TB) (*sqle.Engine, *gitbase.RepositoryPool, func()) {
err = os.Rename(path, pathRepo)
require.NoError(t, err)

lib := plain.NewLibrary("plain")
lib := plain.NewLibrary("plain", nil)
loc, err := plain.NewLocation("location", osfs.New(pathLib), nil)
require.NoError(t, err)
lib.AddLocation(loc)
Expand Down
2 changes: 1 addition & 1 deletion internal/function/commit_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func setupPool(t *testing.T) (*gitbase.RepositoryPool, func()) {
err = os.Rename(path, pathRepo)
require.NoError(t, err)

lib := plain.NewLibrary("plain")
lib := plain.NewLibrary("plain", nil)
loc, err := plain.NewLocation("location", osfs.New(pathLib), nil)
require.NoError(t, err)
lib.AddLocation(loc)
Expand Down
2 changes: 1 addition & 1 deletion internal/function/uast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func setup(t *testing.T) (*sql.Context, func()) {
err = os.Rename(path, pathRepo)
require.NoError(t, err)

lib := plain.NewLibrary("plain")
lib := plain.NewLibrary("plain", nil)
loc, err := plain.NewLocation("location", osfs.New(pathLib), nil)
require.NoError(t, err)
lib.AddLocation(loc)
Expand Down

0 comments on commit 145e71f

Please sign in to comment.