本文整理匯總了Golang中gopkg/in/src-d/go-git/v4/plumbing.Reference.Target方法的典型用法代碼示例。如果您正苦於以下問題:Golang Reference.Target方法的具體用法?Golang Reference.Target怎麽用?Golang Reference.Target使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gopkg/in/src-d/go-git/v4/plumbing.Reference
的用法示例。
在下文中一共展示了Reference.Target方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddReference
func (a *AdvRefs) AddReference(r *plumbing.Reference) error {
switch r.Type() {
case plumbing.SymbolicReference:
v := fmt.Sprintf("%s:%s", r.Name().String(), r.Target().String())
a.Capabilities.Add(capability.SymRef, v)
case plumbing.HashReference:
a.References[r.Name().String()] = r.Hash()
default:
return plumbing.ErrInvalidType
}
return nil
}
示例2: resolveReference
func resolveReference(s ReferenceStorer, r *plumbing.Reference, recursion int) (*plumbing.Reference, error) {
if r.Type() != plumbing.SymbolicReference {
return r, nil
}
if recursion > MaxResolveRecursion {
return nil, ErrMaxResolveRecursion
}
t, err := s.Reference(r.Target())
if err != nil {
return nil, err
}
recursion++
return resolveReference(s, t, recursion)
}
示例3: SetRef
func (d *DotGit) SetRef(r *plumbing.Reference) error {
var content string
switch r.Type() {
case plumbing.SymbolicReference:
content = fmt.Sprintf("ref: %s\n", r.Target())
case plumbing.HashReference:
content = fmt.Sprintln(r.Hash().String())
}
f, err := d.fs.Create(r.Name().String())
if err != nil {
return err
}
if _, err := f.Write([]byte(content)); err != nil {
return err
}
return f.Close()
}