5 Star 11 Fork 7

Gitee 极速下载 / go-git

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/src-d/go-git
克隆/下载
commit_walker.go 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
package object
import (
"io"
"gopkg.in/src-d/go-git.v4/plumbing"
)
type commitWalker struct {
seen map[plumbing.Hash]bool
stack []*CommitIter
start *Commit
cb func(*Commit) error
}
// WalkCommitHistory walks the commit history
func WalkCommitHistory(c *Commit, cb func(*Commit) error) error {
w := &commitWalker{
seen: make(map[plumbing.Hash]bool),
stack: make([]*CommitIter, 0),
start: c,
cb: cb,
}
return w.walk()
}
func (w *commitWalker) walk() error {
var commit *Commit
if w.start != nil {
commit = w.start
w.start = nil
} else {
current := len(w.stack) - 1
if current < 0 {
return nil
}
var err error
commit, err = w.stack[current].Next()
if err == io.EOF {
w.stack = w.stack[:current]
return w.walk()
}
if err != nil {
return err
}
}
// check and update seen
if w.seen[commit.Hash] {
return w.walk()
}
w.seen[commit.Hash] = true
if commit.NumParents() > 0 {
w.stack = append(w.stack, commit.Parents())
}
if err := w.cb(commit); err != nil {
return err
}
return w.walk()
}
Go
1
https://gitee.com/mirrors/go-git.git
git@gitee.com:mirrors/go-git.git
mirrors
go-git
go-git
v4.0.0-rc6

搜索帮助