1package git23import (4 "strings"56 "github.com/aymanbagabas/git-module"7)89const (10 // HEAD represents the name of the HEAD reference.11 HEAD = "HEAD"12 // RefsHeads represents the prefix for branch references.13 RefsHeads = git.RefsHeads14 // RefsTags represents the prefix for tag references.15 RefsTags = git.RefsTags16)1718// Reference is a wrapper around git.Reference with helper methods.19type Reference struct {20 *git.Reference21 path string // repo path22}2324// ReferenceName is a Refspec wrapper.25type ReferenceName string2627// String returns the reference name i.e. refs/heads/master.28func (r ReferenceName) String() string {29 return string(r)30}3132// Short returns the short name of the reference i.e. master.33func (r ReferenceName) Short() string {34 return git.RefShortName(string(r))35}3637// Name returns the reference name i.e. refs/heads/master.38func (r *Reference) Name() ReferenceName {39 return ReferenceName(r.Refspec)40}4142// IsBranch returns true if the reference is a branch.43func (r *Reference) IsBranch() bool {44 return strings.HasPrefix(r.Refspec, git.RefsHeads)45}4647// IsTag returns true if the reference is a tag.48func (r *Reference) IsTag() bool {49 return strings.HasPrefix(r.Refspec, git.RefsTags)50}