aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2015-10-26 01:22:54 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2015-10-26 01:22:54 +0100
commit688e802814f791a8723874dc88437bd8d140e103 (patch)
treeaeaf5e435e5802d9c8ae855a88128a49bc9768c8 /remote.go
parent9a44cd8ccff143a112436c38bfe5581e74b68f07 (diff)
downloadgo-git-688e802814f791a8723874dc88437bd8d140e103.tar.gz
objects: using readers from internal.Object
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/remote.go b/remote.go
index 715d71e..7d21710 100644
--- a/remote.go
+++ b/remote.go
@@ -1,10 +1,12 @@
package git
import (
+ "fmt"
"io"
"gopkg.in/src-d/go-git.v2/clients"
"gopkg.in/src-d/go-git.v2/clients/common"
+ "gopkg.in/src-d/go-git.v2/internal"
)
type Remote struct {
@@ -58,7 +60,22 @@ func (r *Remote) Fetch(req *common.GitUploadPackRequest) (io.ReadCloser, error)
// FetchDefaultBranch returns a reader for the default branch
func (r *Remote) FetchDefaultBranch() (io.ReadCloser, error) {
+ ref, err := r.Ref(r.DefaultBranch())
+ if err != nil {
+ return nil, err
+ }
+
return r.Fetch(&common.GitUploadPackRequest{
- Want: []string{r.upInfo.Refs[r.DefaultBranch()].Id},
+ Want: []internal.Hash{ref},
})
}
+
+// Ref returns the Hash pointing the given refName
+func (r *Remote) Ref(refName string) (internal.Hash, error) {
+ ref, ok := r.upInfo.Refs[refName]
+ if !ok {
+ return internal.NewHash(""), fmt.Errorf("unable to find ref %q", refName)
+ }
+
+ return ref.Id, nil
+}