From 145e71fc4fb6c35703fb9fd7d45d20b99432e1bd Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 23 Aug 2019 10:35:45 +0200 Subject: [PATCH] *: upgrade go-borges to support metadata reload * 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 --- CHANGELOG.md | 4 ++++ _testdata/library.yaml | 2 ++ cmd/gitbase/command/server.go | 10 +++++----- common_test.go | 4 ++-- go.mod | 2 +- go.sum | 6 ++++-- integration_test.go | 12 ++++++------ internal/function/commit_stats_test.go | 2 +- internal/function/uast_test.go | 2 +- 9 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 _testdata/library.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 82840d8cf..d31a18041 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 + +- `go-borges` library was updated to `0.1.1` to support metadata reloading. + ## [0.24.0-beta3] - 2019-07-31 ### Added diff --git a/_testdata/library.yaml b/_testdata/library.yaml new file mode 100644 index 000000000..b0280d3e7 --- /dev/null +++ b/_testdata/library.yaml @@ -0,0 +1,2 @@ +id: d4213320-c4f0-11e9-b018-9cb6d0e2bf3b +version: -1 diff --git a/cmd/gitbase/command/server.go b/cmd/gitbase/command/server.go index 24e73724f..ec13bd5ef 100644 --- a/cmd/gitbase/command/server.go +++ b/cmd/gitbase/command/server.go @@ -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" @@ -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 } @@ -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 diff --git a/common_test.go b/common_test.go index 509f6aebc..1acf0093b 100644 --- a/common_test.go +++ b/common_test.go @@ -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 { diff --git a/go.mod b/go.mod index 4bdfddce4..7a4691c29 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 9b2f2a3d0..d73957640 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/integration_test.go b/integration_test.go index ff02c4064..6cb93e91b 100644 --- a/integration_test.go +++ b/integration_test.go @@ -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" @@ -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) @@ -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) @@ -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) diff --git a/internal/function/commit_stats_test.go b/internal/function/commit_stats_test.go index daceb5082..d93a7546b 100644 --- a/internal/function/commit_stats_test.go +++ b/internal/function/commit_stats_test.go @@ -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) diff --git a/internal/function/uast_test.go b/internal/function/uast_test.go index d7291a9b6..f62758e6a 100644 --- a/internal/function/uast_test.go +++ b/internal/function/uast_test.go @@ -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)