aboutsummaryrefslogtreecommitdiffstats
path: root/examples/basic
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-23 00:37:36 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-23 00:37:36 +0200
commit9ae3c5808fcfa468d1f9394c9b16bc02f573ba79 (patch)
tree917c5dc717c02654baeebd06bef89436ad4c65ec /examples/basic
parent2ed3474ab8e52c98a87e390d5128d45d693a115d (diff)
downloadgo-git-9ae3c5808fcfa468d1f9394c9b16bc02f573ba79.tar.gz
WalkCommitHistory adn Commit.History
Diffstat (limited to 'examples/basic')
-rw-r--r--examples/basic/main.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/examples/basic/main.go b/examples/basic/main.go
index 85d6a57..4cdfa4b 100644
--- a/examples/basic/main.go
+++ b/examples/basic/main.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "strings"
"github.com/fatih/color"
@@ -46,4 +47,16 @@ func main() {
fmt.Printf("100644 blob %s %s\n", f.Hash, f.Name)
return nil
})
+
+ // List the history of the repository
+ // > git log --oneline
+ color.Blue("git log --oneline")
+
+ commits, _ := commit.History()
+ for _, c := range commits {
+ hash := c.Hash.String()
+ line := strings.Split(c.Message, "\n")
+ fmt.Println(hash[:7], line[0])
+ }
+
}