aboutsummaryrefslogtreecommitdiffstats
path: root/tag.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-21 22:53:25 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-21 22:53:25 +0200
commit4912552b913f1f575f9cc358b46bcdbe884e7279 (patch)
treebb9af82a517d32c2d7ce66240989f3c65b2f44b6 /tag.go
parent18d7e8eb4610a224c28ec848692d199669be3e8e (diff)
downloadgo-git-4912552b913f1f575f9cc358b46bcdbe884e7279.tar.gz
tags tests, Tag.String and Commit.String
Diffstat (limited to 'tag.go')
-rw-r--r--tag.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/tag.go b/tag.go
index a056aa9..4d039ab 100644
--- a/tag.go
+++ b/tag.go
@@ -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,
)
}