tried to get a git ref log but failed

This commit is contained in:
Jeff Carr 2025-03-23 04:41:21 -05:00
parent dbf1b08869
commit 8da6cd3ad2
1 changed files with 29 additions and 1 deletions

30
main.go
View File

@ -21,9 +21,37 @@ func main() {
if repo == nil {
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 {
i, err := repo.NewBranchIterator(git.BranchLocal)
if err != nil {