diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-03-22 21:54:27 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-03-22 21:54:27 +0100 |
commit | cfbd64f09f0d068d593f3dc3beb4ea7e62719e34 (patch) | |
tree | 207b0963d151457ec9bf5e3c039854c00c648962 | |
parent | f51d4a8476f865eef27011a9d90e03566c43d59c (diff) | |
download | go-git-cfbd64f09f0d068d593f3dc3beb4ea7e62719e34.tar.gz |
plumbing: ReferenceType as Stringer
-rw-r--r-- | plumbing/reference.go | 13 | ||||
-rw-r--r-- | plumbing/reference_test.go | 4 |
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") } |