aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-14 23:12:44 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-14 23:12:44 +0100
commit0af572dd21c0aa79d13745b633ee24ba6c4d6cf1 (patch)
tree49e81e74e82d84fd88b2fc1e4b0dc7c7bfe9c40f /examples
parentdf0f38af83f972f026d7e14150f3d37b95f13484 (diff)
downloadgo-git-0af572dd21c0aa79d13745b633ee24ba6c4d6cf1.tar.gz
move plumbing from top level package to plumbing (#183)
* plumbing: rename Object -> EncodedObject. * plumbing/storer: rename ObjectStorer -> EncodedObjectStorer. * move difftree to plumbing/difftree. * move diff -> utils/diff * make Object/Tag/Blob/Tree/Commit/File depend on storer. * Object and its implementations now depend only on storer.EncodedObjectStorer, not git.Repository. * Tests are decoupled accordingly. * move Object/Commit/File/Tag/Tree to plumbing/object. * move Object/Commit/File/Tag/Tree to plumbing/object. * move checkClose to utils/ioutil. * move RevListObjects to plumbing/revlist.Objects. * move DiffTree to plumbing/difftree package. * rename files with plural nouns to singular * plumbing/object: add GetBlob/GetCommit/GetTag/GetTree.
Diffstat (limited to 'examples')
-rw-r--r--examples/showcase/main.go4
-rw-r--r--examples/storage/aerospike/storage.go20
2 files changed, 13 insertions, 11 deletions
diff --git a/examples/showcase/main.go b/examples/showcase/main.go
index ff5c7d3..4d1206d 100644
--- a/examples/showcase/main.go
+++ b/examples/showcase/main.go
@@ -6,6 +6,8 @@ import (
"strings"
"gopkg.in/src-d/go-git.v4"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
+
. "gopkg.in/src-d/go-git.v4/examples"
)
@@ -42,7 +44,7 @@ func main() {
CheckIfError(err)
// ... get the files iterator and print the file
- tree.Files().ForEach(func(f *git.File) error {
+ tree.Files().ForEach(func(f *object.File) error {
fmt.Printf("100644 blob %s %s\n", f.Hash, f.Name)
return nil
})
diff --git a/examples/storage/aerospike/storage.go b/examples/storage/aerospike/storage.go
index a1d8c00..87d4a29 100644
--- a/examples/storage/aerospike/storage.go
+++ b/examples/storage/aerospike/storage.go
@@ -33,11 +33,11 @@ func NewStorage(client *driver.Client, ns, url string) (*Storage, error) {
return &Storage{client: client, ns: ns, url: url}, nil
}
-func (s *Storage) NewObject() plumbing.Object {
+func (s *Storage) NewEncodedObject() plumbing.EncodedObject {
return &plumbing.MemoryObject{}
}
-func (s *Storage) SetObject(obj plumbing.Object) (plumbing.Hash, error) {
+func (s *Storage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.Hash, error) {
key, err := s.buildKey(obj.Hash(), obj.Type())
if err != nil {
return obj.Hash(), err
@@ -64,7 +64,7 @@ func (s *Storage) SetObject(obj plumbing.Object) (plumbing.Hash, error) {
return obj.Hash(), err
}
-func (s *Storage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Object, error) {
+func (s *Storage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) {
key, err := s.buildKey(h, t)
if err != nil {
return nil, err
@@ -82,7 +82,7 @@ func (s *Storage) Object(t plumbing.ObjectType, h plumbing.Hash) (plumbing.Objec
return objectFromRecord(rec, t)
}
-func (s *Storage) IterObjects(t plumbing.ObjectType) (storer.ObjectIter, error) {
+func (s *Storage) IterEncodedObjects(t plumbing.ObjectType) (storer.EncodedObjectIter, error) {
stmnt := driver.NewStatement(s.ns, t.String())
err := stmnt.Addfilter(driver.NewEqualFilter(urlField, s.url))
@@ -91,19 +91,19 @@ func (s *Storage) IterObjects(t plumbing.ObjectType) (storer.ObjectIter, error)
return nil, err
}
- return &ObjectIter{t, rs.Records}, nil
+ return &EncodedObjectIter{t, rs.Records}, nil
}
func (s *Storage) buildKey(h plumbing.Hash, t plumbing.ObjectType) (*driver.Key, error) {
return driver.NewKey(s.ns, t.String(), fmt.Sprintf("%s|%s", s.url, h.String()))
}
-type ObjectIter struct {
+type EncodedObjectIter struct {
t plumbing.ObjectType
ch chan *driver.Record
}
-func (i *ObjectIter) Next() (plumbing.Object, error) {
+func (i *EncodedObjectIter) Next() (plumbing.EncodedObject, error) {
r := <-i.ch
if r == nil {
return nil, io.EOF
@@ -112,7 +112,7 @@ func (i *ObjectIter) Next() (plumbing.Object, error) {
return objectFromRecord(r, i.t)
}
-func (i *ObjectIter) ForEach(cb func(obj plumbing.Object) error) error {
+func (i *EncodedObjectIter) ForEach(cb func(obj plumbing.EncodedObject) error) error {
for {
obj, err := i.Next()
if err != nil {
@@ -133,9 +133,9 @@ func (i *ObjectIter) ForEach(cb func(obj plumbing.Object) error) error {
}
}
-func (i *ObjectIter) Close() {}
+func (i *EncodedObjectIter) Close() {}
-func objectFromRecord(r *driver.Record, t plumbing.ObjectType) (plumbing.Object, error) {
+func objectFromRecord(r *driver.Record, t plumbing.ObjectType) (plumbing.EncodedObject, error) {
content := r.Bins["blob"].([]byte)
o := &plumbing.MemoryObject{}