本文整理匯總了Golang中gopkg/in/src-d/go-git/v4/plumbing.ReferenceName.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReferenceName.String方法的具體用法?Golang ReferenceName.String怎麽用?Golang ReferenceName.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gopkg/in/src-d/go-git/v4/plumbing.ReferenceName
的用法示例。
在下文中一共展示了ReferenceName.String方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: matchGlob
func (s RefSpec) matchGlob(n plumbing.ReferenceName) bool {
src := s.Src()
name := n.String()
wildcard := strings.Index(src, refSpecWildcard)
var prefix, suffix string
prefix = src[0:wildcard]
if len(src) < wildcard {
suffix = src[wildcard+1 : len(suffix)]
}
return len(name) > len(prefix)+len(suffix) &&
strings.HasPrefix(name, prefix) &&
strings.HasSuffix(name, suffix)
}
示例2: Dst
// Dst returns the destination for the given remote reference
func (s RefSpec) Dst(n plumbing.ReferenceName) plumbing.ReferenceName {
spec := string(s)
start := strings.Index(spec, refSpecSeparator) + 1
dst := spec[start:]
src := s.Src()
if !s.IsWildcard() {
return plumbing.ReferenceName(dst)
}
name := n.String()
ws := strings.Index(src, refSpecWildcard)
wd := strings.Index(dst, refSpecWildcard)
match := name[ws : len(name)-(len(src)-(ws+1))]
return plumbing.ReferenceName(dst[0:wd] + match + dst[wd+1:])
}
示例3: Ref
// Ref returns the reference for a given reference name.
func (d *DotGit) Ref(name plumbing.ReferenceName) (*plumbing.Reference, error) {
ref, err := d.readReferenceFile(".", name.String())
if err == nil {
return ref, nil
}
refs, err := d.Refs()
if err != nil {
return nil, err
}
for _, ref := range refs {
if ref.Name() == name {
return ref, nil
}
}
return nil, plumbing.ErrReferenceNotFound
}
示例4: matchExact
func (s RefSpec) matchExact(n plumbing.ReferenceName) bool {
return s.Src() == n.String()
}