From f42d82364c5d159f65a48e720433ad2bc97f0b7f Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Mon, 22 Aug 2016 00:18:02 +0200 Subject: Remote.Fetch multiple RefSpec support --- options.go | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'options.go') diff --git a/options.go b/options.go index 414b7f0..3691a6f 100644 --- a/options.go +++ b/options.go @@ -2,7 +2,6 @@ package git import ( "errors" - "fmt" "gopkg.in/src-d/go-git.v3/clients/common" "gopkg.in/src-d/go-git.v4/config" @@ -11,9 +10,7 @@ import ( const ( // DefaultRemoteName name of the default Remote, just like git command - DefaultRemoteName = "origin" - DefaultSingleBranchRefSpec = "+refs/heads/%s:refs/remotes/%s/%[1]s" - DefaultRefSpec = "+refs/heads/*:refs/remotes/%s/*" + DefaultRemoteName = "origin" ) var ( @@ -54,22 +51,6 @@ func (o *RepositoryCloneOptions) Validate() error { return nil } -func (o *RepositoryCloneOptions) refSpec(s core.ReferenceStorage) (config.RefSpec, error) { - var spec string - if o.SingleBranch { - head, err := core.ResolveReference(s, o.ReferenceName) - if err != nil { - return "", err - } - - spec = fmt.Sprintf(DefaultSingleBranchRefSpec, head.Name().Short(), o.RemoteName) - } else { - spec = fmt.Sprintf(DefaultRefSpec, o.RemoteName) - } - - return config.RefSpec(spec), nil -} - // RepositoryPullOptions describe how a pull should be perform type RepositoryPullOptions struct { // Name of the remote to be pulled @@ -97,14 +78,16 @@ func (o *RepositoryPullOptions) Validate() error { // RemoteFetchOptions describe how a fetch should be perform type RemoteFetchOptions struct { - RefSpec config.RefSpec - Depth int + RefSpecs []config.RefSpec + Depth int } // Validate validate the fields and set the default values func (o *RemoteFetchOptions) Validate() error { - if !o.RefSpec.IsValid() { - return ErrInvalidRefSpec + for _, r := range o.RefSpecs { + if !r.IsValid() { + return ErrInvalidRefSpec + } } return nil -- cgit