MCPcopy Create free account
hub / github.com/go-git/go-git / deleteReferences

Method deleteReferences

remote.go:675–711  ·  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

673}
674
675func (r *Remote) deleteReferences(rs config.RefSpec,
676 remoteRefs storer.ReferenceStorer,
677 refsDict map[string]*plumbing.Reference,
678 req *packp.ReferenceUpdateRequest,
679 prune bool) error {
680 iter, err := remoteRefs.IterReferences()
681 if err != nil {
682 return err
683 }
684
685 return iter.ForEach(func(ref *plumbing.Reference) error {
686 if ref.Type() != plumbing.HashReference {
687 return nil
688 }
689
690 if prune {
691 rs := rs.Reverse()
692 if !rs.Match(ref.Name()) {
693 return nil
694 }
695
696 if _, ok := refsDict[rs.Dst(ref.Name()).String()]; ok {
697 return nil
698 }
699 } else if rs.Dst("") != ref.Name() {
700 return nil
701 }
702
703 cmd := &packp.Command{
704 Name: ref.Name(),
705 Old: ref.Hash(),
706 New: plumbing.ZeroHash,
707 }
708 req.Commands = append(req.Commands, cmd)
709 return nil
710 })
711}
712
713func (r *Remote) addCommit(rs config.RefSpec,
714 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