diff options
| author | Jeff Carr <[email protected]> | 2025-03-22 21:38:02 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-22 21:38:02 -0500 |
| commit | dbf1b088692b741d4f35e5f7d7ad99bbd327f70d (patch) | |
| tree | e367d2b2b51d6f7db93fe37bfc4836483f24a9d6 /main.go | |
| parent | b5643f83bef98d940f34a987a477436f91710e80 (diff) | |
more on branches
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -1,13 +1,51 @@ package main +import ( + "os" + + git "go.wit.com/lib/libgit2" + "go.wit.com/log" +) + // are sent via -ldflags at buildtime var VERSION string var BUILDTIME string func main() { + var repo *git.Repository if argv.Refs { - showRefs() + repo, _ = showRefs() } else { testMessage() } + if repo == nil { + os.Exit(-1) + } + walkBranches(repo) +} + +func walkBranches(repo *git.Repository) *git.Branch { + i, err := repo.NewBranchIterator(git.BranchLocal) + if err != nil { + log.Info("walkBranches() error", err) + return nil + } + + for { + b, bt, err := i.Next() + if git.IsErrorCode(err, git.ErrorCodeIterOver) { + return nil + } + name, _ := b.Name() + if name == "jcarr" { + log.Info("found BranchLocal", name) + return b + } + if bt == git.BranchLocal { + log.Info("BranchLocal", name) + } else { + log.Info("Branch", name, bt) + } + } + return nil } |
