aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-15 23:09:33 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-15 23:09:33 +0200
commit6b9a59be60de5b66aee14e9160ace80734008eca (patch)
treec302776360b0fd4f774f67f177870fda478b4258 /repository.go
parented2e3b299e03e4bfd4c37bf5232e9fde05c0600d (diff)
downloadgo-git-6b9a59be60de5b66aee14e9160ace80734008eca.tar.gz
core: *Iter.ForEach method
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go37
1 files changed, 8 insertions, 29 deletions
diff --git a/repository.go b/repository.go
index e9aa55a..170a1b4 100644
--- a/repository.go
+++ b/repository.go
@@ -2,7 +2,6 @@ package git
import (
"errors"
- "io"
"gopkg.in/src-d/go-git.v4/clients/common"
"gopkg.in/src-d/go-git.v4/core"
@@ -128,24 +127,14 @@ func (r *Repository) getAllRemoteRefences(remote *Remote) ([]*core.Reference, er
i := remote.Refs()
defer i.Close()
- for {
- ref, err := i.Next()
- if err != nil {
- if err == io.EOF {
- break
- }
-
- return nil, err
- }
-
+ return refs, i.ForEach(func(ref *core.Reference) error {
if !ref.IsBranch() {
- continue
+ return nil
}
refs = append(refs, ref)
- }
-
- return refs, nil
+ return nil
+ })
}
func (r *Repository) createLocalReferences(ref *core.Reference) error {
@@ -234,24 +223,14 @@ func (r *Repository) getLocalReferences() ([]*core.Reference, error) {
i := r.Refs()
defer i.Close()
- for {
- ref, err := i.Next()
- if err != nil {
- if err == io.EOF {
- break
- }
-
- return nil, err
- }
-
+ return refs, i.ForEach(func(ref *core.Reference) error {
if ref.Type() == core.SymbolicReference {
- continue
+ return nil
}
refs = append(refs, ref)
- }
-
- return refs, nil
+ return nil
+ })
}
// Commit return the commit with the given hash