| 1 | package gitscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/ |
| 2 | |
| 3 | import ( |
| 4 | "stringsscip-go gomod github.com/golang/go/src go1.16 strings/" |
| 5 | |
| 6 | "github.com/go-git/go-git/v5/plumbingscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/" |
| 7 | "github.com/go-git/go-git/v5/plumbing/storerscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/" |
| 8 | ) |
| 9 | |
| 10 | // RemoteBranch is the wrapper of go-git's Reference struct. In addition to |
| 11 | // that, it also holds name of the remote branch |
| 12 | type RemoteBranchscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/RemoteBranch# struct { |
| 13 | Namescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/RemoteBranch#Name. string |
| 14 | Referencescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/RemoteBranch#Reference. *plumbingscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/.Referencescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/Reference# |
| 15 | } |
| 16 | |
| 17 | // search for the remote branches of the remote. It takes the go-git's repo |
| 18 | // pointer in order to get storer struct |
| 19 | func (rm *Remotescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Remote#) loadRemoteBranchesscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Remote#loadRemoteBranches().(r *Repositoryscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#) error { |
| 20 | rm.Branchesscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Remote#Branches. = make([]*RemoteBranchscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/RemoteBranch#, 0) |
| 21 | bs, err := remoteBranchesIterscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/remoteBranchesIter().(r.Reposcip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Repository#Repo..Storerscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5`/Repository#Storer.) |
| 22 | if err != nil { |
| 23 | return err |
| 24 | } |
| 25 | defer bs.Closescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/ReferenceIter#Close().() |
| 26 | err = bs.ForEachscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/ReferenceIter#ForEach().(func(b *plumbingscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/.Referencescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/Reference#) error { |
| 27 | if stringsscip-go gomod github.com/golang/go/src go1.16 strings/.Splitscip-go gomod github.com/golang/go/src go1.16 strings/Split().(b.Namescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/Reference#Name().().Shortscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/ReferenceName#Short().(), "/")[0] == rm.Namescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Remote#Name. { |
| 28 | rm.Branchesscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Remote#Branches. = append(rm.Branchesscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/Remote#Branches., &RemoteBranchscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/RemoteBranch#{ |
| 29 | Namescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/RemoteBranch#Name.: b.Namescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/Reference#Name().().Shortscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/ReferenceName#Short().(), |
| 30 | Referencescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/RemoteBranch#Reference.: b, |
| 31 | }) |
| 32 | } |
| 33 | return nil |
| 34 | }) |
| 35 | return err |
| 36 | } |
| 37 | |
| 38 | // create an iterator for the references. it checks if the reference is a hash |
| 39 | // reference |
| 40 | func remoteBranchesIterscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/remoteBranchesIter().(s storerscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/.ReferenceStorerscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/ReferenceStorer#) (storerscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/.ReferenceIterscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/ReferenceIter#, error) { |
| 41 | refs, err := s.IterReferencesscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/ReferenceStorer#IterReferences().() |
| 42 | if err != nil { |
| 43 | return nil, err |
| 44 | } |
| 45 | |
| 46 | return storerscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/.NewReferenceFilteredIterscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing/storer`/NewReferenceFilteredIter().(func(ref *plumbingscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/.Referencescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/Reference#) bool { |
| 47 | if ref.Typescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/Reference#Type().() == plumbingscip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/.HashReferencescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/HashReference. { |
| 48 | return ref.Namescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/Reference#Name().().IsRemotescip-go gomod github.com/go-git/go-git/v5 v5.1.0 `github.com/go-git/go-git/v5/plumbing`/ReferenceName#IsRemote().() |
| 49 | } |
| 50 | return false |
| 51 | }, refs), nil |
| 52 | } |