diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-15 03:51:04 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-15 03:51:04 +0200 |
commit | bcb49927a3897eadc29960032c70da29e26d6b58 (patch) | |
tree | 60025a0a59d15e49c6027b1bfd5d6fee5d5d2438 /remote.go | |
parent | f6fe29c80d11662a169806dcf413ecdedcb28fa3 (diff) | |
download | go-git-bcb49927a3897eadc29960032c70da29e26d6b58.tar.gz |
Repository.Clone and Remote.Fetch remote, local branches and client: correct header read
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -9,6 +9,7 @@ import ( // Remote represents a connection to a remote repository type Remote struct { + Name string Endpoint common.Endpoint Auth common.AuthMethod @@ -17,13 +18,13 @@ type Remote struct { } // NewRemote returns a new Remote, using as client http.DefaultClient -func NewRemote(url string) (*Remote, error) { - return NewAuthenticatedRemote(url, nil) +func NewRemote(name, url string) (*Remote, error) { + return NewAuthenticatedRemote(name, url, nil) } // NewAuthenticatedRemote returns a new Remote using the given AuthMethod, using as // client http.DefaultClient -func NewAuthenticatedRemote(url string, auth common.AuthMethod) (*Remote, error) { +func NewAuthenticatedRemote(name, url string, auth common.AuthMethod) (*Remote, error) { endpoint, err := common.NewEndpoint(url) if err != nil { return nil, err @@ -36,6 +37,7 @@ func NewAuthenticatedRemote(url string, auth common.AuthMethod) (*Remote, error) return &Remote{ Endpoint: endpoint, + Name: name, Auth: auth, upSrv: upSrv, }, nil @@ -77,16 +79,17 @@ func (r *Remote) Capabilities() *common.Capabilities { } // Fetch returns a reader using the request -func (r *Remote) Fetch(s core.ObjectStorage, o *FetchOptions) (err error) { - o.Default() +func (r *Remote) Fetch(s core.ObjectStorage, o *RemoteFetchOptions) (err error) { + req := &common.GitUploadPackRequest{} + req.Depth = o.Depth - ref, err := r.Ref(o.ReferenceName, true) - if err != nil { - return err - } + for _, ref := range o.References { + if ref.Type() != core.HashReference { + continue + } - req := &common.GitUploadPackRequest{} - req.Want(ref.Hash()) + req.Want(ref.Hash()) + } reader, err := r.upSrv.Fetch(req) if err != nil { |