aboutsummaryrefslogtreecommitdiffstats
path: root/core/reference.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-14 18:21:10 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-14 18:21:10 +0200
commitf6fe29c80d11662a169806dcf413ecdedcb28fa3 (patch)
tree9958034c27521f720f8c5d83c12120ada196f48a /core/reference.go
parent91bf16b2336e6f80f0742be729582fe5fbbada83 (diff)
downloadgo-git-f6fe29c80d11662a169806dcf413ecdedcb28fa3.tar.gz
core: Storage, removing err returning *Storages
Diffstat (limited to 'core/reference.go')
-rw-r--r--core/reference.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/reference.go b/core/reference.go
index 7d3f378..3ec95a0 100644
--- a/core/reference.go
+++ b/core/reference.go
@@ -132,6 +132,21 @@ func (r *Reference) IsTag() bool {
return strings.HasPrefix(string(r.n), refTagPrefix)
}
+// Strings dump a reference as a [2]string
+func (r *Reference) Strings() [2]string {
+ var o [2]string
+ o[0] = r.Name().String()
+
+ switch r.Type() {
+ case HashReference:
+ o[1] = r.Hash().String()
+ case SymbolicReference:
+ o[1] = symrefPrefix + r.Target().String()
+ }
+
+ return o
+}
+
// ReferenceSliceIter implements ReferenceIter. It iterates over a series of
// references stored in a slice and yields each one in turn when Next() is
// called.