aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-15 03:51:04 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-15 03:51:04 +0200
commitbcb49927a3897eadc29960032c70da29e26d6b58 (patch)
tree60025a0a59d15e49c6027b1bfd5d6fee5d5d2438 /remote.go
parentf6fe29c80d11662a169806dcf413ecdedcb28fa3 (diff)
downloadgo-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.go25
1 files changed, 14 insertions, 11 deletions
diff --git a/remote.go b/remote.go
index a9e0409..ce74af4 100644
--- a/remote.go
+++ b/remote.go
@@ -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 {