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

Method update

submodule.go:248–284  ·  view source on GitHub ↗
(ctx context.Context, o *SubmoduleUpdateOptions, forceHash plumbing.Hash)

Source from the content-addressed store, hash-verified

246}
247
248func (s *Submodule) update(ctx context.Context, o *SubmoduleUpdateOptions, forceHash plumbing.Hash) error {
249 if !s.initialized && !o.Init {
250 return ErrSubmoduleNotInitialized
251 }
252
253 if !s.initialized && o.Init {
254 if err := s.Init(); err != nil {
255 return err
256 }
257 }
258
259 idx, err := s.w.r.Storer.Index()
260 if err != nil {
261 return err
262 }
263
264 hash := forceHash
265 if hash.IsZero() {
266 e, err := idx.Entry(s.c.Path)
267 if err != nil {
268 return err
269 }
270
271 hash = e.Hash
272 }
273
274 r, err := s.Repository()
275 if err != nil {
276 return err
277 }
278
279 if err := s.fetchAndCheckout(ctx, r, o, hash); err != nil {
280 return err
281 }
282
283 return s.doRecursiveUpdate(ctx, r, o)
284}
285
286func (s *Submodule) doRecursiveUpdate(ctx context.Context, r *Repository, o *SubmoduleUpdateOptions) error {
287 if o.RecurseSubmodules == NoRecurseSubmodules {

Callers 1

UpdateContextMethod · 0.95

Calls 7

InitMethod · 0.95
RepositoryMethod · 0.95
fetchAndCheckoutMethod · 0.95
doRecursiveUpdateMethod · 0.95
EntryMethod · 0.80
IndexMethod · 0.65
IsZeroMethod · 0.65

Tested by

no test coverage detected