summaryrefslogtreecommitdiff
path: root/refs.go
diff options
context:
space:
mode:
Diffstat (limited to 'refs.go')
-rw-r--r--refs.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/refs.go b/refs.go
index aec9c91..2b6d1f6 100644
--- a/refs.go
+++ b/refs.go
@@ -2,6 +2,7 @@ package syw
import "strings"
+// Ref is an object representing a commit in a repository.
type Ref struct {
Repo *Repository
Name string
@@ -11,6 +12,7 @@ type Ref struct {
func (r Ref) IsBranch() bool { return strings.HasPrefix(r.Name, "refs/heads/") }
func (r Ref) IsTag() bool { return strings.HasPrefix(r.Name, "refs/tags/") }
+// ShortName returns the branch or tag name with "refs/[heads|tags]/" trimmed off.
func (r Ref) ShortName() string {
if r.IsBranch() {
return r.Name[11:]