aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-03-22 21:54:27 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-03-22 21:54:27 +0100
commitcfbd64f09f0d068d593f3dc3beb4ea7e62719e34 (patch)
tree207b0963d151457ec9bf5e3c039854c00c648962 /plumbing
parentf51d4a8476f865eef27011a9d90e03566c43d59c (diff)
downloadgo-git-cfbd64f09f0d068d593f3dc3beb4ea7e62719e34.tar.gz
plumbing: ReferenceType as Stringer
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/reference.go13
-rw-r--r--plumbing/reference_test.go4
2 files changed, 17 insertions, 0 deletions
diff --git a/plumbing/reference.go b/plumbing/reference.go
index b9f4a95..798c3dd 100644
--- a/plumbing/reference.go
+++ b/plumbing/reference.go
@@ -28,6 +28,19 @@ const (
SymbolicReference ReferenceType = 2
)
+func (r ReferenceType) String() string {
+ switch r {
+ case InvalidReference:
+ return "invalid-reference"
+ case HashReference:
+ return "hash-reference"
+ case SymbolicReference:
+ return "symbolic-reference"
+ }
+
+ return ""
+}
+
// ReferenceName reference name's
type ReferenceName string
diff --git a/plumbing/reference_test.go b/plumbing/reference_test.go
index 4d9b393..849f159 100644
--- a/plumbing/reference_test.go
+++ b/plumbing/reference_test.go
@@ -10,6 +10,10 @@ const (
ExampleReferenceName ReferenceName = "refs/heads/v4"
)
+func (s *ReferenceSuite) TestReferenceTypeString(c *C) {
+ c.Assert(SymbolicReference.String(), Equals, "symbolic-reference")
+}
+
func (s *ReferenceSuite) TestReferenceNameShort(c *C) {
c.Assert(ExampleReferenceName.Short(), Equals, "v4")
}