diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-06-18 12:15:40 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-06-18 12:15:40 +0200 |
commit | abb9ec0f3efea571b7f19b7391eb7c152c899f45 (patch) | |
tree | 703bcd8caf958007e90d6694e5225084b3ddfdb5 /plumbing/transport/server | |
parent | bf3a92052f715c507ace0cb9f2b7fb358f623abc (diff) | |
download | go-git-abb9ec0f3efea571b7f19b7391eb7c152c899f45.tar.gz |
*: upgrade to go-billy.v3, merge
Diffstat (limited to 'plumbing/transport/server')
-rw-r--r-- | plumbing/transport/server/loader.go | 10 | ||||
-rw-r--r-- | plumbing/transport/server/server_test.go | 22 |
2 files changed, 15 insertions, 17 deletions
diff --git a/plumbing/transport/server/loader.go b/plumbing/transport/server/loader.go index 386c2f0..d4eccd4 100644 --- a/plumbing/transport/server/loader.go +++ b/plumbing/transport/server/loader.go @@ -5,8 +5,8 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/transport" "gopkg.in/src-d/go-git.v4/storage/filesystem" - "gopkg.in/src-d/go-billy.v2" - "gopkg.in/src-d/go-billy.v2/osfs" + "gopkg.in/src-d/go-billy.v3" + "gopkg.in/src-d/go-billy.v3/osfs" ) // DefaultLoader is a filesystem loader ignoring host and resolving paths to /. @@ -34,7 +34,11 @@ func NewFilesystemLoader(base billy.Filesystem) Loader { // storer for it. Returns transport.ErrRepositoryNotFound if a repository does // not exist in the given path. func (l *fsLoader) Load(ep transport.Endpoint) (storer.Storer, error) { - fs := l.base.Dir(ep.Path()) + fs, err := l.base.Chroot(ep.Path()) + if err != nil { + return nil, err + } + if _, err := fs.Stat("config"); err != nil { return nil, transport.ErrRepositoryNotFound } diff --git a/plumbing/transport/server/server_test.go b/plumbing/transport/server/server_test.go index 6a64674..0f7201c 100644 --- a/plumbing/transport/server/server_test.go +++ b/plumbing/transport/server/server_test.go @@ -1,7 +1,6 @@ package server_test import ( - "fmt" "testing" "github.com/src-d/go-git-fixtures" @@ -16,8 +15,6 @@ import ( func Test(t *testing.T) { TestingT(t) } -const inprocScheme = "inproc" - type BaseSuite struct { fixtures.Suite loader server.MapLoader @@ -29,15 +26,15 @@ func (s *BaseSuite) SetUpSuite(c *C) { s.Suite.SetUpSuite(c) s.loader = server.MapLoader{} s.client = server.NewServer(s.loader) - s.clientBackup = client.Protocols[inprocScheme] - client.Protocols[inprocScheme] = s.client + s.clientBackup = client.Protocols["file"] + client.Protocols["file"] = s.client } func (s *BaseSuite) TearDownSuite(c *C) { if s.clientBackup == nil { - delete(client.Protocols, inprocScheme) + delete(client.Protocols, "file") } else { - client.Protocols[inprocScheme] = s.clientBackup + client.Protocols["file"] = s.clientBackup } } @@ -46,9 +43,8 @@ func (s *BaseSuite) prepareRepositories(c *C, basic *transport.Endpoint, f := fixtures.Basic().One() fs := f.DotGit() - path := fs.Base() - url := fmt.Sprintf("%s://%s", inprocScheme, path) - ep, err := transport.NewEndpoint(url) + path := fs.Root() + ep, err := transport.NewEndpoint(path) c.Assert(err, IsNil) *basic = ep sto, err := filesystem.NewStorage(fs) @@ -56,15 +52,13 @@ func (s *BaseSuite) prepareRepositories(c *C, basic *transport.Endpoint, s.loader[ep.String()] = sto path = "/empty.git" - url = fmt.Sprintf("%s://%s", inprocScheme, path) - ep, err = transport.NewEndpoint(url) + ep, err = transport.NewEndpoint(path) c.Assert(err, IsNil) *empty = ep s.loader[ep.String()] = memory.NewStorage() path = "/non-existent.git" - url = fmt.Sprintf("%s://%s", inprocScheme, path) - ep, err = transport.NewEndpoint(url) + ep, err = transport.NewEndpoint(path) c.Assert(err, IsNil) *nonExistent = ep } |