diff options
author | Colton McCurdy <mccurdyc22@gmail.com> | 2018-11-01 08:01:34 -0400 |
---|---|---|
committer | Colton McCurdy <mccurdyc22@gmail.com> | 2018-11-01 08:01:34 -0400 |
commit | 3fe6f65a9955d25d51d195d5d4ce43339c813534 (patch) | |
tree | 5b1f0168b856665a1fb2a9eabab3af4bb056e28f /plumbing/reference.go | |
parent | 43d4551b4b6e49af1a1402047b3a81fbcd6a85e9 (diff) | |
parent | 959dc01faa3352c0b41ff0fa257239f5f00165db (diff) | |
download | go-git-3fe6f65a9955d25d51d195d5d4ce43339c813534.tar.gz |
Merge branch 'master' of github.com:src-d/go-git into mccurdyc/Issue#969/fix-flaky-ssh-test
Diffstat (limited to 'plumbing/reference.go')
-rw-r--r-- | plumbing/reference.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/plumbing/reference.go b/plumbing/reference.go index 2f53d4e..08e908f 100644 --- a/plumbing/reference.go +++ b/plumbing/reference.go @@ -55,6 +55,36 @@ func (r ReferenceType) String() string { // ReferenceName reference name's type ReferenceName string +// NewBranchReferenceName returns a reference name describing a branch based on +// his short name. +func NewBranchReferenceName(name string) ReferenceName { + return ReferenceName(refHeadPrefix + name) +} + +// NewNoteReferenceName returns a reference name describing a note based on his +// short name. +func NewNoteReferenceName(name string) ReferenceName { + return ReferenceName(refNotePrefix + name) +} + +// NewRemoteReferenceName returns a reference name describing a remote branch +// based on his short name and the remote name. +func NewRemoteReferenceName(remote, name string) ReferenceName { + return ReferenceName(refRemotePrefix + fmt.Sprintf("%s/%s", remote, name)) +} + +// NewRemoteHEADReferenceName returns a reference name describing a the HEAD +// branch of a remote. +func NewRemoteHEADReferenceName(remote string) ReferenceName { + return ReferenceName(refRemotePrefix + fmt.Sprintf("%s/%s", remote, HEAD)) +} + +// NewTagReferenceName returns a reference name describing a tag based on short +// his name. +func NewTagReferenceName(name string) ReferenceName { + return ReferenceName(refTagPrefix + name) +} + // IsBranch check if a reference is a branch func (r ReferenceName) IsBranch() bool { return strings.HasPrefix(string(r), refHeadPrefix) |