本文整理汇总了Golang中gopkg/in/src-d/go-git/v4/plumbing.Reference.Hash方法的典型用法代码示例。如果您正苦于以下问题:Golang Reference.Hash方法的具体用法?Golang Reference.Hash怎么用?Golang Reference.Hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/src-d/go-git/v4/plumbing.Reference
的用法示例。
在下文中一共展示了Reference.Hash方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createReferences
func (r *Repository) createReferences(ref *plumbing.Reference) error {
if !ref.IsBranch() {
// detached HEAD mode
head := plumbing.NewHashReference(plumbing.HEAD, ref.Hash())
return r.s.SetReference(head)
}
if err := r.s.SetReference(ref); err != nil {
return err
}
head := plumbing.NewSymbolicReference(plumbing.HEAD, ref.Name())
return r.s.SetReference(head)
}
示例3: Fetch
func (f *Fetcher) Fetch(w io.Writer, ref *plumbing.Reference) (written int64, err error) {
if err := f.service.Connect(); err != nil {
return 0, err
}
req := &common.GitUploadPackRequest{}
req.Want(ref.Hash())
r, err := f.service.Fetch(req)
if err != nil {
return 0, err
}
return io.Copy(w, r)
}
示例4: addReferenceIfRefSpecMatches
func (r *Remote) addReferenceIfRefSpecMatches(rs config.RefSpec,
remoteRefs storer.ReferenceStorer, localRef *plumbing.Reference,
req *packp.ReferenceUpdateRequest) error {
if localRef.Type() != plumbing.HashReference {
return nil
}
if !rs.Match(localRef.Name()) {
return nil
}
dstName := rs.Dst(localRef.Name())
oldHash := plumbing.ZeroHash
newHash := localRef.Hash()
iter, err := remoteRefs.IterReferences()
if err != nil {
return err
}
err = iter.ForEach(func(remoteRef *plumbing.Reference) error {
if remoteRef.Type() != plumbing.HashReference {
return nil
}
if dstName != remoteRef.Name() {
return nil
}
oldHash = remoteRef.Hash()
return nil
})
if oldHash == newHash {
return nil
}
req.Commands = append(req.Commands, &packp.Command{
Name: dstName,
Old: oldHash,
New: newHash,
})
return nil
}
示例5: 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()
}
示例6: mutateTagToBranch
// we mutate the tag into a branch to avoid detached branches
func (s *Server) mutateTagToBranch(ref *plumbing.Reference, constraint string) *plumbing.Reference {
branch := plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", constraint))
return plumbing.NewHashReference(branch, ref.Hash())
}