summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/main.go b/main.go
index b2b0123..cb42b98 100644
--- a/main.go
+++ b/main.go
@@ -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 {