tried to get a git ref log but failed
This commit is contained in:
parent
dbf1b08869
commit
8da6cd3ad2
30
main.go
30
main.go
|
@ -21,9 +21,37 @@ func main() {
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
walkBranches(repo)
|
b := walkBranches(repo)
|
||||||
|
|
||||||
|
// o, err := b.Reference.Peel(b.Reference.Type())
|
||||||
|
o, err := b.Reference.Peel(git.ObjectTree)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("ref peel() failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t, errt := o.AsTree()
|
||||||
|
if errt != nil {
|
||||||
|
log.Info("object AsTree() failed", errt)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
walkTree(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lists the files in the git repo
|
||||||
|
// Makefile, .gitignore, README.md, etc
|
||||||
|
func walkTree(tree *git.Tree) {
|
||||||
|
var callCount int
|
||||||
|
err := tree.Walk(func(name string, entry *git.TreeEntry) error {
|
||||||
|
callCount++
|
||||||
|
log.Info("walkTree()", callCount, entry.Name, entry.Id, entry.Type)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
log.Info("walkTree() count", callCount, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// lists the branches
|
||||||
|
// "master", "devel", "jcarr"
|
||||||
func walkBranches(repo *git.Repository) *git.Branch {
|
func walkBranches(repo *git.Repository) *git.Branch {
|
||||||
i, err := repo.NewBranchIterator(git.BranchLocal)
|
i, err := repo.NewBranchIterator(git.BranchLocal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue