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

Method update

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

Source from the content-addressed store, hash-verified

180}
181
182func (s *Submodule) update(ctx context.Context, o *SubmoduleUpdateOptions, forceHash plumbing.Hash) error {
183 if !s.initialized && !o.Init {
184 return ErrSubmoduleNotInitialized
185 }
186
187 if !s.initialized && o.Init {
188 if err := s.Init(); err != nil {
189 return err
190 }
191 }
192
193 idx, err := s.w.r.Storer.Index()
194 if err != nil {
195 return err
196 }
197
198 hash := forceHash
199 if hash.IsZero() {
200 e, err := idx.Entry(s.c.Path)
201 if err != nil {
202 return err
203 }
204
205 hash = e.Hash
206 }
207
208 r, err := s.Repository()
209 if err != nil {
210 return err
211 }
212
213 if err := s.fetchAndCheckout(ctx, r, o, hash); err != nil {
214 return err
215 }
216
217 return s.doRecursiveUpdate(r, o)
218}
219
220func (s *Submodule) doRecursiveUpdate(r *Repository, o *SubmoduleUpdateOptions) error {
221 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