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 /commit.go | |
parent | 18d7e8eb4610a224c28ec848692d199669be3e8e (diff) | |
download | go-git-4912552b913f1f575f9cc358b46bcdbe884e7279.tar.gz |
tags tests, Tag.String and Commit.String
Diffstat (limited to 'commit.go')
-rw-r--r-- | commit.go | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -6,6 +6,7 @@ import ( "fmt" "io" "sort" + "strings" "gopkg.in/src-d/go-git.v4/core" ) @@ -184,11 +185,25 @@ func (b *Commit) Encode(o core.Object) error { func (c *Commit) String() string { return fmt.Sprintf( - "%s %s\nAuthor: %s\nDate: %s\n", - core.CommitObject, c.Hash, c.Author.String(), c.Author.When, + "%s %s\nAuthor: %s\nDate: %s\n\n%s\n", + core.CommitObject, c.Hash, c.Author.String(), + c.Author.When.Format(DateFormat), indent(c.Message), ) } +func indent(t string) string { + var output []string + for _, line := range strings.Split(t, "\n") { + if len(line) != 0 { + line = " " + line + } + + output = append(output, line) + } + + return strings.Join(output, "\n") +} + // CommitIter provides an iterator for a set of commits. type CommitIter struct { core.ObjectIter |