aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2017-11-01 21:06:37 +0200
committerJeremy Stribling <strib@alum.mit.edu>2017-11-29 10:40:46 -0800
commitac1914eac3c20efa63de8809229994364ad9639b (patch)
tree4595bfceec10aea603517e5dc7f493b93e068d30 /plumbing
parenta6202cacd12aa5ee20c54aff799b0e91330526c5 (diff)
downloadgo-git-ac1914eac3c20efa63de8809229994364ad9639b.tar.gz
First pass of prune design
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/storer/object.go14
-rw-r--r--plumbing/storer/object_test.go13
2 files changed, 27 insertions, 0 deletions
diff --git a/plumbing/storer/object.go b/plumbing/storer/object.go
index e793211..5d043cb 100644
--- a/plumbing/storer/object.go
+++ b/plumbing/storer/object.go
@@ -3,6 +3,7 @@ package storer
import (
"errors"
"io"
+ "time"
"gopkg.in/src-d/go-git.v4/plumbing"
)
@@ -36,6 +37,19 @@ type EncodedObjectStorer interface {
//
// Valid plumbing.ObjectType values are CommitObject, BlobObject, TagObject,
IterEncodedObjects(plumbing.ObjectType) (EncodedObjectIter, error)
+ // HasEncodedObject returns ErrObjNotFound if the object doesn't
+ // exist. If the object does exist, it returns nil.
+ HasEncodedObject(plumbing.Hash) error
+ // ForEachObjectHash iterates over all the (loose) object hashes
+ // in the repository without necessarily having to read those objects.
+ // Objects only inside pack files may be omitted.
+ ForEachObjectHash(func(plumbing.Hash) error) error
+ // LooseObjectTime looks up the (m)time associated with the
+ // loose object (that is not in a pack file). Implementations
+ // may
+ LooseObjectTime(plumbing.Hash) (time.Time, error)
+ // DeleteLooseObject deletes a loose object if it exists.
+ DeleteLooseObject(plumbing.Hash) error
}
// DeltaObjectStorer is an EncodedObjectStorer that can return delta
diff --git a/plumbing/storer/object_test.go b/plumbing/storer/object_test.go
index 6bdd25c..f8b1f73 100644
--- a/plumbing/storer/object_test.go
+++ b/plumbing/storer/object_test.go
@@ -3,6 +3,7 @@ package storer
import (
"fmt"
"testing"
+ "time"
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -148,3 +149,15 @@ func (o *MockObjectStorage) IterEncodedObjects(t plumbing.ObjectType) (EncodedOb
func (o *MockObjectStorage) Begin() Transaction {
return nil
}
+
+func (o *MockObjectStorage) ForEachObjectHash(fun func(plumbing.Hash) error) error {
+ return nil
+}
+
+func (o *MockObjectStorage) LooseObjectTime(plumbing.Hash) (time.Time, error) {
+ return time.Time{}, plumbing.ErrObjectNotFound
+}
+
+func (o *MockObjectStorage) DeleteLooseObject(plumbing.Hash) error {
+ return plumbing.ErrObjectNotFound
+}