blob: b2b0123d201ebfb482ad13d129a4c957b1b9f98f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 {
		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
}
  |