aboutsummaryrefslogtreecommitdiffstats
path: root/commit.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 /commit.go
parent18d7e8eb4610a224c28ec848692d199669be3e8e (diff)
downloadgo-git-4912552b913f1f575f9cc358b46bcdbe884e7279.tar.gz
tags tests, Tag.String and Commit.String
Diffstat (limited to 'commit.go')
-rw-r--r--commit.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/commit.go b/commit.go
index 8bb675a..a66cef8 100644
--- a/commit.go
+++ b/commit.go
@@ -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