diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-21 22:53:25 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-21 22:53:25 +0200 |
commit | 4912552b913f1f575f9cc358b46bcdbe884e7279 (patch) | |
tree | bb9af82a517d32c2d7ce66240989f3c65b2f44b6 /tag.go | |
parent | 18d7e8eb4610a224c28ec848692d199669be3e8e (diff) | |
download | go-git-4912552b913f1f575f9cc358b46bcdbe884e7279.tar.gz |
tags tests, Tag.String and Commit.String
Diffstat (limited to 'tag.go')
-rw-r--r-- | tag.go | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -113,20 +113,25 @@ func (t *Tag) Encode(o core.Object) error { return err } defer checkClose(w, &err) + if _, err = fmt.Fprintf(w, "object %s\ntype %s\ntag %s\ntagger ", t.Target.String(), t.TargetType.Bytes(), t.Name); err != nil { return err } + if err = t.Tagger.Encode(w); err != nil { return err } + if _, err = fmt.Fprint(w, "\n\n"); err != nil { return err } + if _, err = fmt.Fprint(w, t.Message); err != nil { return err } + return err } @@ -143,7 +148,6 @@ func (t *Tag) Commit() (*Commit, error) { // object the tree of that commit will be returned. If the tag does not point // to a commit or tree object ErrUnsupportedObject will be returned. func (t *Tag) Tree() (*Tree, error) { - // TODO: If the tag is of type commit, follow the commit to its tree? switch t.TargetType { case core.CommitObject: commit, err := t.r.Commit(t.Target) @@ -175,9 +179,11 @@ func (t *Tag) Object() (Object, error) { // String returns the meta information contained in the tag as a formatted // string. func (t *Tag) String() string { + obj, _ := t.Object() return fmt.Sprintf( - "%s %s\nObject: %s\nType: %s\nTag: %s\nTagger: %s\nDate: %s\n", - core.TagObject, t.Hash, t.Target, t.TargetType, t.Name, t.Tagger.String(), t.Tagger.When, + "%s %s\nTagger: %s\nDate: %s\n\n%s\n%s", + core.TagObject, t.Name, t.Tagger.String(), t.Tagger.When.Format(DateFormat), + t.Message, obj, ) } |