diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-11 23:16:48 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-11 23:16:48 +0200 |
commit | 7a428a915ce2b7bb0f4fc6dcee77932ebacfabbf (patch) | |
tree | a116c49d89ae0450c9999a85896d1a10ba7d8a0b /_examples/open/main.go | |
parent | 116fed7ea746255805f5664d9b6fd7cdb1b52663 (diff) | |
parent | 9b45f468c61a0756dd19d09b64c2b1a88cc99ec5 (diff) | |
download | go-git-7a428a915ce2b7bb0f4fc6dcee77932ebacfabbf.tar.gz |
merge, Repository.Log
Diffstat (limited to '_examples/open/main.go')
-rw-r--r-- | _examples/open/main.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/_examples/open/main.go b/_examples/open/main.go index 0000f5e..b890423 100644 --- a/_examples/open/main.go +++ b/_examples/open/main.go @@ -6,6 +6,7 @@ import ( "gopkg.in/src-d/go-git.v4" . "gopkg.in/src-d/go-git.v4/_examples" + "gopkg.in/src-d/go-git.v4/plumbing/object" ) // Open an existing repository in a specific folder. @@ -24,13 +25,18 @@ func main() { ref, err := r.Head() CheckIfError(err) - // ... retrieving the commit object - commit, err := r.CommitObject(ref.Hash()) + // ... retrieves the commit history + cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) CheckIfError(err) - // ... calculating the commit history - commits, err := commit.History() + // ... just iterates over the commits + var cCount int + err = cIter.ForEach(func(c *object.Commit) error { + cCount++ + + return nil + }) CheckIfError(err) - fmt.Println(len(commits)) + fmt.Println(cCount) } |