aboutsummaryrefslogtreecommitdiffstats
path: root/core/object.go
diff options
context:
space:
mode:
authorJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-18 23:17:57 -0800
committerJoshua Sjoding <joshua.sjoding@scjalliance.com>2016-02-18 23:17:57 -0800
commitf23141ac004d672bb8ea22a709b8c3ed1cdb8b89 (patch)
tree22e511b6c8e97945ccd0d6060b1eb2fefe6c0506 /core/object.go
parent8e4fb520044f01e3f79c03e4752005dddc359188 (diff)
downloadgo-git-f23141ac004d672bb8ea22a709b8c3ed1cdb8b89.tar.gz
Added ParseObjectType function to core
Diffstat (limited to 'core/object.go')
-rw-r--r--core/object.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/object.go b/core/object.go
index e64f650..74ea555 100644
--- a/core/object.go
+++ b/core/object.go
@@ -64,6 +64,28 @@ func (t ObjectType) Bytes() []byte {
return []byte(t.String())
}
+// ParseObjectType parses a string representation of ObjectType. It returns an
+// error on parse failure.
+func ParseObjectType(value string) (typ ObjectType, err error) {
+ switch value {
+ case "commit":
+ typ = CommitObject
+ case "tree":
+ typ = TreeObject
+ case "blob":
+ typ = BlobObject
+ case "tag":
+ typ = TagObject
+ case "ofs-delta":
+ typ = OFSDeltaObject
+ case "ref-delta":
+ typ = REFDeltaObject
+ default:
+ err = errors.New("unable to parse object type")
+ }
+ return
+}
+
// ObjectIter is a generic closable interface for iterating over objects.
type ObjectIter interface {
Next() (Object, error)