(ctx context.Context, o *SubmoduleUpdateOptions, forceHash plumbing.Hash)
| 246 | } |
| 247 | |
| 248 | func (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 | |
| 286 | func (s *Submodule) doRecursiveUpdate(ctx context.Context, r *Repository, o *SubmoduleUpdateOptions) error { |
| 287 | if o.RecurseSubmodules == NoRecurseSubmodules { |
no test coverage detected