本文整理匯總了Golang中gopkg/in/src-d/go-git/v4/plumbing/storer.ReferenceStorer類的典型用法代碼示例。如果您正苦於以下問題:Golang ReferenceStorer類的具體用法?Golang ReferenceStorer怎麽用?Golang ReferenceStorer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ReferenceStorer類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: buildRequest
func (r *Remote) buildRequest(
s storer.ReferenceStorer, o *FetchOptions, refs []*plumbing.Reference,
) (*common.GitUploadPackRequest, error) {
req := &common.GitUploadPackRequest{}
req.Depth = o.Depth
for _, ref := range refs {
req.Want(ref.Hash())
}
i, err := s.IterReferences()
if err != nil {
return nil, err
}
err = i.ForEach(func(ref *plumbing.Reference) error {
if ref.Type() != plumbing.HashReference {
return nil
}
req.Have(ref.Hash())
return nil
})
return req, err
}
示例2: getWants
func getWants(spec []config.RefSpec, localStorer Storer, remoteRefs storer.ReferenceStorer) ([]plumbing.Hash, error) {
wantTags := true
for _, s := range spec {
if !s.IsWildcard() {
wantTags = false
break
}
}
iter, err := remoteRefs.IterReferences()
if err != nil {
return nil, err
}
wants := map[plumbing.Hash]bool{}
err = iter.ForEach(func(ref *plumbing.Reference) error {
if !config.MatchAny(spec, ref.Name()) {
if !ref.IsTag() || !wantTags {
return nil
}
}
if ref.Type() == plumbing.SymbolicReference {
ref, err = storer.ResolveReference(remoteRefs, ref.Name())
if err != nil {
return err
}
}
if ref.Type() != plumbing.HashReference {
return nil
}
hash := ref.Hash()
exists, err := commitExists(localStorer, hash)
if err != nil {
return err
}
if !exists {
wants[hash] = true
}
return nil
})
if err != nil {
return nil, err
}
var result []plumbing.Hash
for h := range wants {
result = append(result, h)
}
return result, nil
}
示例3: addRefs
func addRefs(s storer.ReferenceStorer, ar *AdvRefs) error {
for name, hash := range ar.References {
ref := plumbing.NewReferenceFromStrings(name, hash.String())
if err := s.SetReference(ref); err != nil {
return err
}
}
return addSymbolicRefs(s, ar)
}
示例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: referencesToHashes
func referencesToHashes(refs storer.ReferenceStorer) ([]plumbing.Hash, error) {
iter, err := refs.IterReferences()
if err != nil {
return nil, err
}
var hs []plumbing.Hash
err = iter.ForEach(func(ref *plumbing.Reference) error {
if ref.Type() != plumbing.HashReference {
return nil
}
hs = append(hs, ref.Hash())
return nil
})
if err != nil {
return nil, err
}
return hs, nil
}
示例6: getHaves
func getHaves(localRefs storer.ReferenceStorer) ([]plumbing.Hash, error) {
iter, err := localRefs.IterReferences()
if err != nil {
return nil, err
}
var haves []plumbing.Hash
err = iter.ForEach(func(ref *plumbing.Reference) error {
if ref.Type() != plumbing.HashReference {
return nil
}
haves = append(haves, ref.Hash())
return nil
})
if err != nil {
return nil, err
}
return haves, nil
}
示例7: addSymbolicRefs
func addSymbolicRefs(s storer.ReferenceStorer, ar *AdvRefs) error {
if !hasSymrefs(ar) {
return nil
}
for _, symref := range ar.Capabilities.Get(capability.SymRef) {
chunks := strings.Split(symref, ":")
if len(chunks) != 2 {
err := fmt.Errorf("bad number of `:` in symref value (%q)", symref)
return plumbing.NewUnexpectedError(err)
}
name := plumbing.ReferenceName(chunks[0])
target := plumbing.ReferenceName(chunks[1])
ref := plumbing.NewSymbolicReference(name, target)
if err := s.SetReference(ref); err != nil {
return nil
}
}
return nil
}
示例8: buildFetchedTags
func (r *Remote) buildFetchedTags(refs storer.ReferenceStorer) error {
iter, err := refs.IterReferences()
if err != nil {
return err
}
return iter.ForEach(func(ref *plumbing.Reference) error {
if !ref.IsTag() {
return nil
}
_, err := r.s.EncodedObject(plumbing.AnyObject, ref.Hash())
if err == plumbing.ErrObjectNotFound {
return nil
}
if err != nil {
return err
}
return r.s.SetReference(ref)
})
}