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

Function checkAndUpdateReferenceStorerIfNeeded

repository.go:1155–1173  ·  view source on GitHub ↗
(
	s storer.ReferenceStorer, r, old *plumbing.Reference)

Source from the content-addressed store, hash-verified

1153}
1154
1155func checkAndUpdateReferenceStorerIfNeeded(
1156 s storer.ReferenceStorer, r, old *plumbing.Reference) (
1157 updated bool, err error) {
1158 p, err := s.Reference(r.Name())
1159 if err != nil && err != plumbing.ErrReferenceNotFound {
1160 return false, err
1161 }
1162
1163 // we use the string method to compare references, is the easiest way
1164 if err == plumbing.ErrReferenceNotFound || r.String() != p.String() {
1165 if err := s.CheckAndSetReference(r, old); err != nil {
1166 return false, err
1167 }
1168
1169 return true, nil
1170 }
1171
1172 return false, nil
1173}
1174
1175func updateReferenceStorerIfNeeded(
1176 s storer.ReferenceStorer, r *plumbing.Reference) (updated bool, err error) {

Callers 2

Calls 4

ReferenceMethod · 0.65
NameMethod · 0.65
StringMethod · 0.65
CheckAndSetReferenceMethod · 0.65

Tested by

no test coverage detected