Esempio n. 1
0
File: repo.go Progetto: sombr/ccat
func (r *Repository) Branches(_ vcs.BranchesOptions) ([]*vcs.Branch, error) {
	r.editLock.RLock()
	defer r.editLock.RUnlock()

	refs, err := r.u.NewReferenceIterator()
	if err != nil {
		return nil, err
	}

	var bs []*vcs.Branch
	for {
		ref, err := refs.Next()
		if isErrIterOver(err) {
			break
		}
		if err != nil {
			return nil, err
		}
		if ref.IsBranch() {
			bs = append(bs, &vcs.Branch{Name: ref.Shorthand(), Head: vcs.CommitID(ref.Target().String())})
		}
	}

	sort.Sort(vcs.Branches(bs))
	return bs, nil
}
Esempio n. 2
0
File: repo.go Progetto: sombr/ccat
func (r *Repository) Branches(_ vcs.BranchesOptions) ([]*vcs.Branch, error) {
	bs := make([]*vcs.Branch, len(r.branchHeads.IdByName))
	i := 0
	for name, id := range r.branchHeads.IdByName {
		bs[i] = &vcs.Branch{Name: name, Head: vcs.CommitID(id)}
		i++
	}
	sort.Sort(vcs.Branches(bs))
	return bs, nil
}