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

Method addOrUpdateReferences

remote.go:656–687  ·  view source on GitHub ↗
(
	rs config.RefSpec,
	localRefs []*plumbing.Reference,
	refsDict map[string]*plumbing.Reference,
	remoteRefs storer.ReferenceStorer,
	req *packp.ReferenceUpdateRequest,
	forceWithLease *ForceWithLease,
)

Source from the content-addressed store, hash-verified

654}
655
656func (r *Remote) addOrUpdateReferences(
657 rs config.RefSpec,
658 localRefs []*plumbing.Reference,
659 refsDict map[string]*plumbing.Reference,
660 remoteRefs storer.ReferenceStorer,
661 req *packp.ReferenceUpdateRequest,
662 forceWithLease *ForceWithLease,
663) error {
664 // If it is not a wildcard refspec we can directly search for the reference
665 // in the references dictionary.
666 if !rs.IsWildcard() {
667 ref, ok := refsDict[rs.Src()]
668 if !ok {
669 commit, err := object.GetCommit(r.s, plumbing.NewHash(rs.Src()))
670 if err == nil {
671 return r.addCommit(rs, remoteRefs, commit.Hash, req)
672 }
673 return nil
674 }
675
676 return r.addReferenceIfRefSpecMatches(rs, remoteRefs, ref, req, forceWithLease)
677 }
678
679 for _, ref := range localRefs {
680 err := r.addReferenceIfRefSpecMatches(rs, remoteRefs, ref, req, forceWithLease)
681 if err != nil {
682 return err
683 }
684 }
685
686 return nil
687}
688
689func (r *Remote) deleteReferences(rs config.RefSpec,
690 remoteRefs storer.ReferenceStorer,

Callers 1

addReferencesToUpdateMethod · 0.95

Calls 6

addCommitMethod · 0.95
GetCommitFunction · 0.92
NewHashFunction · 0.92
IsWildcardMethod · 0.80
SrcMethod · 0.80

Tested by

no test coverage detected