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 } }