MCPcopy
hub / github.com/go-git/go-git / deleteReferences

Method deleteReferences

remote.go:689–725  ·  view source on GitHub ↗
(rs config.RefSpec,
	remoteRefs storer.ReferenceStorer,
	refsDict map[string]*plumbing.Reference,
	req *packp.ReferenceUpdateRequest,
	prune bool)

Source from the content-addressed store, hash-verified

687}
688
689func (r *Remote) deleteReferences(rs config.RefSpec,
690 remoteRefs storer.ReferenceStorer,
691 refsDict map[string]*plumbing.Reference,
692 req *packp.ReferenceUpdateRequest,
693 prune bool) error {
694 iter, err := remoteRefs.IterReferences()
695 if err != nil {
696 return err
697 }
698
699 return iter.ForEach(func(ref *plumbing.Reference) error {
700 if ref.Type() != plumbing.HashReference {
701 return nil
702 }
703
704 if prune {
705 rs := rs.Reverse()
706 if !rs.Match(ref.Name()) {
707 return nil
708 }
709
710 if _, ok := refsDict[rs.Dst(ref.Name()).String()]; ok {
711 return nil
712 }
713 } else if rs.Dst("") != ref.Name() {
714 return nil
715 }
716
717 cmd := &packp.Command{
718 Name: ref.Name(),
719 Old: ref.Hash(),
720 New: plumbing.ZeroHash,
721 }
722 req.Commands = append(req.Commands, cmd)
723 return nil
724 })
725}
726
727func (r *Remote) addCommit(rs config.RefSpec,
728 remoteRefs storer.ReferenceStorer, localCommit plumbing.Hash,

Callers 1

addReferencesToUpdateMethod · 0.95

Calls 9

ReverseMethod · 0.80
DstMethod · 0.80
IterReferencesMethod · 0.65
ForEachMethod · 0.65
TypeMethod · 0.65
MatchMethod · 0.65
NameMethod · 0.65
StringMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected