fork of go-git with some jj specific features
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modify examples

+24 -15
+7 -7
_examples/log/main.go
··· 5 5 6 6 "gopkg.in/src-d/go-git.v4" 7 7 . "gopkg.in/src-d/go-git.v4/_examples" 8 + "gopkg.in/src-d/go-git.v4/plumbing/object" 8 9 "gopkg.in/src-d/go-git.v4/storage/memory" 9 10 ) 10 11 ··· 29 30 ref, err := r.Head() 30 31 CheckIfError(err) 31 32 32 - // ... retrieves the commit object 33 - commit, err := r.CommitObject(ref.Hash()) 34 - CheckIfError(err) 35 - 36 33 // ... retrieves the commit history 37 - history, err := commit.History() 34 + cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) 38 35 CheckIfError(err) 39 36 40 37 // ... just iterates over the commits, printing it 41 - for _, c := range history { 38 + err = cIter.ForEach(func(c *object.Commit) error { 42 39 fmt.Println(c) 43 - } 40 + 41 + return nil 42 + }) 43 + CheckIfError(err) 44 44 }
+11 -5
_examples/open/main.go
··· 6 6 7 7 "gopkg.in/src-d/go-git.v4" 8 8 . "gopkg.in/src-d/go-git.v4/_examples" 9 + "gopkg.in/src-d/go-git.v4/plumbing/object" 9 10 ) 10 11 11 12 // Open an existing repository in a specific folder. ··· 24 25 ref, err := r.Head() 25 26 CheckIfError(err) 26 27 27 - // ... retrieving the commit object 28 - commit, err := r.CommitObject(ref.Hash()) 28 + // ... retrieves the commit history 29 + cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) 29 30 CheckIfError(err) 30 31 31 - // ... calculating the commit history 32 - commits, err := commit.History() 32 + // ... just iterates over the commits 33 + var cCount int 34 + err = cIter.ForEach(func(c *object.Commit) error { 35 + cCount++ 36 + 37 + return nil 38 + }) 33 39 CheckIfError(err) 34 40 35 - fmt.Println(len(commits)) 41 + fmt.Println(cCount) 36 42 }
+6 -3
_examples/showcase/main.go
··· 59 59 // List the history of the repository 60 60 Info("git log --oneline") 61 61 62 - commits, err := commit.History() 62 + commitIter, err := r.Log(&git.LogOptions{From: commit.Hash}) 63 63 CheckIfError(err) 64 64 65 - for _, c := range commits { 65 + err = commitIter.ForEach(func(c *object.Commit) error { 66 66 hash := c.Hash.String() 67 67 line := strings.Split(c.Message, "\n") 68 68 fmt.Println(hash[:7], line[0]) 69 - } 69 + 70 + return nil 71 + }) 72 + CheckIfError(err) 70 73 }