From 79087748f60f9aba219624a0fe9f4d33a0b51236 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Sat, 13 Aug 2016 22:32:34 +0200 Subject: Repository.Clone and Remote.Fetch tests and improvements --- core/reference.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core/reference.go') diff --git a/core/reference.go b/core/reference.go index 4be4971..7d3f378 100644 --- a/core/reference.go +++ b/core/reference.go @@ -34,6 +34,20 @@ const ( // ReferenceName reference name's type ReferenceName string +// AsRemote returns a new remote reference name using current one as base +func (r ReferenceName) AsRemote(remote string) ReferenceName { + return ReferenceName(refRemotePrefix + remote + "/" + r.alias()) +} + +func (r ReferenceName) String() string { + return string(r) +} + +func (r ReferenceName) alias() string { + parts := strings.Split(string(r), "/") + return parts[len(parts)-1] +} + const ( HEAD ReferenceName = "HEAD" ) -- cgit