aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-12 01:59:53 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-12 01:59:53 +0200
commit805cc777b083fee68a8834ebe1823d0b9dc6a00f (patch)
treee497602859f7e238072a31d20477db6a656f6482 /remote.go
parent68307cee4259c6c4fded8124af7f993f0266a545 (diff)
downloadgo-git-805cc777b083fee68a8834ebe1823d0b9dc6a00f.tar.gz
general: usage of the new Reference objects
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go34
1 files changed, 8 insertions, 26 deletions
diff --git a/remote.go b/remote.go
index f450271..ecbcd54 100644
--- a/remote.go
+++ b/remote.go
@@ -77,45 +77,27 @@ func (r *Remote) Capabilities() *common.Capabilities {
return r.upInfo.Capabilities
}
-// DefaultBranch returns the name of the remote's default branch
-func (r *Remote) DefaultBranch() string {
- return r.upInfo.Capabilities.SymbolicReference("HEAD")
-}
-
-// Head returns the Hash of the HEAD
-func (r *Remote) Head() (core.Hash, error) {
- return r.Ref(r.DefaultBranch())
-}
-
// Fetch returns a reader using the request
func (r *Remote) Fetch(req *common.GitUploadPackRequest) (io.ReadCloser, error) {
return r.upSrv.Fetch(req)
}
-// 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
- }
-
- req := &common.GitUploadPackRequest{}
- req.Want(ref)
-
- return r.Fetch(req)
+// Head returns the Hash of the HEAD
+func (r *Remote) Head() *core.Reference {
+ return r.upInfo.Head()
}
// Ref returns the Hash pointing the given refName
-func (r *Remote) Ref(refName string) (core.Hash, error) {
- ref, ok := r.upInfo.Refs[refName]
+func (r *Remote) Ref(name core.ReferenceName) (*core.Reference, error) {
+ ref, ok := r.upInfo.Refs[name]
if !ok {
- return core.NewHash(""), fmt.Errorf("unable to find ref %q", refName)
+ return nil, fmt.Errorf("unable to find ref %q", name)
}
return ref, nil
}
-// Refs returns the Hash pointing the given refName
-func (r *Remote) Refs() map[string]core.Hash {
+// Refs returns a map with all the References
+func (r *Remote) Refs() map[core.ReferenceName]*core.Reference {
return r.upInfo.Refs
}