aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-02-27 23:50:04 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-02-27 23:50:04 +0100
commit9c9cdff966cc181296f400769d3c8596f17e743a (patch)
treeddd60f794c193e1a407e78b5ca94d0a83466fd78 /core
parent1e74b17f05ad27818df39818a0d22107a0b4b424 (diff)
parent31f920a06aa5d7e7cf363645dac02f6e798fffb1 (diff)
downloadgo-git-9c9cdff966cc181296f400769d3c8596f17e743a.tar.gz
Merge pull request #37 from scjalliance/objfile-format
Added support for objfile format
Diffstat (limited to 'core')
-rw-r--r--core/object.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/object.go b/core/object.go
index d56a44a..9958570 100644
--- a/core/object.go
+++ b/core/object.go
@@ -8,6 +8,8 @@ import (
var (
ObjectNotFoundErr = errors.New("object not found")
+ // ErrInvalidType is returned when an invalid object type is provided.
+ ErrInvalidType = errors.New("invalid object type")
)
// TODO: Consider adding a Hash function to the ObjectReader and ObjectWriter
@@ -79,6 +81,11 @@ func (t ObjectType) Bytes() []byte {
return []byte(t.String())
}
+// Valid returns true if t is a valid ObjectType.
+func (t ObjectType) Valid() bool {
+ return t >= CommitObject && t <= REFDeltaObject
+}
+
// ParseObjectType parses a string representation of ObjectType. It returns an
// error on parse failure.
func ParseObjectType(value string) (typ ObjectType, err error) {
@@ -96,7 +103,7 @@ func ParseObjectType(value string) (typ ObjectType, err error) {
case "ref-delta":
typ = REFDeltaObject
default:
- err = errors.New("unable to parse object type")
+ err = ErrInvalidType
}
return
}