Skip to content

Commit e7cf6d2

Browse files
authored
Merge pull request go-git#857 from erizocosmico/feature/object-storage-public
storage: filesystem, make ObjectStorage constructor public
2 parents b235700 + ecd2bd5 commit e7cf6d2

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

storage/filesystem/object.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ type ObjectStorage struct {
2626
index map[plumbing.Hash]*packfile.Index
2727
}
2828

29-
func newObjectStorage(dir *dotgit.DotGit) (ObjectStorage, error) {
29+
// NewObjectStorage creates a new ObjectStorage with the given .git directory.
30+
func NewObjectStorage(dir *dotgit.DotGit) (ObjectStorage, error) {
3031
s := ObjectStorage{
3132
deltaBaseCache: cache.NewObjectLRUDefault(),
3233
dir: dir,
@@ -166,7 +167,7 @@ func (s *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (p
166167
// Create a new object storage with the DotGit(s) and check for the
167168
// required hash object. Skip when not found.
168169
for _, dg := range dotgits {
169-
o, oe := newObjectStorage(dg)
170+
o, oe := NewObjectStorage(dg)
170171
if oe != nil {
171172
continue
172173
}

storage/filesystem/object_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var _ = Suite(&FsSuite{
2424

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

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

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

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

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

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

9292
iter, err := o.IterEncodedObjects(t)

storage/filesystem/storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Storage struct {
2525
// NewStorage returns a new Storage backed by a given `fs.Filesystem`
2626
func NewStorage(fs billy.Filesystem) (*Storage, error) {
2727
dir := dotgit.New(fs)
28-
o, err := newObjectStorage(dir)
28+
o, err := NewObjectStorage(dir)
2929
if err != nil {
3030
return nil, err
3131
}

0 commit comments

Comments
 (0)