diff options
Diffstat (limited to 'refs.go')
-rw-r--r-- | refs.go | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +package syw + +import "strings" + +type Ref struct { + Repo *Repository + Name string + Hash string +} + +func (r Ref) IsBranch() bool { return strings.HasPrefix(r.Name, "refs/heads/") } +func (r Ref) IsTag() bool { return strings.HasPrefix(r.Name, "refs/tags/") } + +func (r Ref) ShortName() string { + if r.IsBranch() { + return r.Name[11:] + } else if r.IsTag() { + return r.Name[10:] + } else { + return r.Name + } +} |