diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-02-20 00:45:00 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-02-20 00:45:00 +0100 |
commit | 9c319b2c4d6bb5cff43d237583b463619e95dc93 (patch) | |
tree | b32c906cef4779c9cec73749400e1a48eff10bf5 /core/object.go | |
parent | ffe26fecc9b1435054d851ef93f156536f2a4584 (diff) | |
parent | 916755f7652d4a3189aa717c7f2668c9aa0b1373 (diff) | |
download | go-git-9c319b2c4d6bb5cff43d237583b463619e95dc93.tar.gz |
Merge pull request #32 from scjalliance/annotated-tags
Annotated tags
Diffstat (limited to 'core/object.go')
-rw-r--r-- | core/object.go | 22 |
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) |