Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

storage: filesystem, make ObjectStorage constructor public #857

Merged
merged 1 commit into from
Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions storage/filesystem/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ type ObjectStorage struct {
index map[plumbing.Hash]*packfile.Index
}

func newObjectStorage(dir *dotgit.DotGit) (ObjectStorage, error) {
// NewObjectStorage creates a new ObjectStorage with the given .git directory.
func NewObjectStorage(dir *dotgit.DotGit) (ObjectStorage, error) {
s := ObjectStorage{
deltaBaseCache: cache.NewObjectLRUDefault(),
dir: dir,
Expand Down Expand Up @@ -166,7 +167,7 @@ func (s *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (p
// Create a new object storage with the DotGit(s) and check for the
// required hash object. Skip when not found.
for _, dg := range dotgits {
o, oe := newObjectStorage(dg)
o, oe := NewObjectStorage(dg)
if oe != nil {
continue
}
Expand Down
10 changes: 5 additions & 5 deletions storage/filesystem/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var _ = Suite(&FsSuite{

func (s *FsSuite) TestGetFromObjectFile(c *C) {
fs := fixtures.ByTag(".git").ByTag("unpacked").One().DotGit()
o, err := newObjectStorage(dotgit.New(fs))
o, err := NewObjectStorage(dotgit.New(fs))
c.Assert(err, IsNil)

expected := plumbing.NewHash("f3dfe29d268303fc6e1bbce268605fc99573406e")
Expand All @@ -36,7 +36,7 @@ func (s *FsSuite) TestGetFromObjectFile(c *C) {
func (s *FsSuite) TestGetFromPackfile(c *C) {
fixtures.Basic().ByTag(".git").Test(c, func(f *fixtures.Fixture) {
fs := f.DotGit()
o, err := newObjectStorage(dotgit.New(fs))
o, err := NewObjectStorage(dotgit.New(fs))
c.Assert(err, IsNil)

expected := plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
Expand All @@ -48,7 +48,7 @@ func (s *FsSuite) TestGetFromPackfile(c *C) {

func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
fs := fixtures.ByTag(".git").ByTag("multi-packfile").One().DotGit()
o, err := newObjectStorage(dotgit.New(fs))
o, err := NewObjectStorage(dotgit.New(fs))
c.Assert(err, IsNil)

expected := plumbing.NewHash("8d45a34641d73851e01d3754320b33bb5be3c4d3")
Expand All @@ -65,7 +65,7 @@ func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
func (s *FsSuite) TestIter(c *C) {
fixtures.ByTag(".git").ByTag("packfile").Test(c, func(f *fixtures.Fixture) {
fs := f.DotGit()
o, err := newObjectStorage(dotgit.New(fs))
o, err := NewObjectStorage(dotgit.New(fs))
c.Assert(err, IsNil)

iter, err := o.IterEncodedObjects(plumbing.AnyObject)
Expand All @@ -86,7 +86,7 @@ func (s *FsSuite) TestIterWithType(c *C) {
fixtures.ByTag(".git").Test(c, func(f *fixtures.Fixture) {
for _, t := range s.Types {
fs := f.DotGit()
o, err := newObjectStorage(dotgit.New(fs))
o, err := NewObjectStorage(dotgit.New(fs))
c.Assert(err, IsNil)

iter, err := o.IterEncodedObjects(t)
Expand Down
2 changes: 1 addition & 1 deletion storage/filesystem/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Storage struct {
// NewStorage returns a new Storage backed by a given `fs.Filesystem`
func NewStorage(fs billy.Filesystem) (*Storage, error) {
dir := dotgit.New(fs)
o, err := newObjectStorage(dir)
o, err := NewObjectStorage(dir)
if err != nil {
return nil, err
}
Expand Down