PlainCloneContext a repository into the path with the given options, isBare defines if the new repository will be bare or normal. If the path is not empty ErrRepositoryAlreadyExists is returned. The provided Context must be non-nil. If the context expires before the operation is complete, an error
(ctx context.Context, path string, isBare bool, o *CloneOptions)
| 477 | // TODO(mcuadros): move isBare to CloneOptions in v5 |
| 478 | // TODO(smola): refuse upfront to clone on a non-empty directory in v5, see #1027 |
| 479 | func PlainCloneContext(ctx context.Context, path string, isBare bool, o *CloneOptions) (*Repository, error) { |
| 480 | cleanup, cleanupParent, err := checkIfCleanupIsNeeded(path) |
| 481 | if err != nil { |
| 482 | return nil, err |
| 483 | } |
| 484 | |
| 485 | if o.Mirror { |
| 486 | isBare = true |
| 487 | } |
| 488 | r, err := PlainInit(path, isBare) |
| 489 | if err != nil { |
| 490 | return nil, err |
| 491 | } |
| 492 | |
| 493 | err = r.clone(ctx, o) |
| 494 | if err != nil && err != ErrRepositoryAlreadyExists { |
| 495 | if cleanup { |
| 496 | _ = cleanUpDir(path, cleanupParent) |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | return r, err |
| 501 | } |
| 502 | |
| 503 | func newRepository(s storage.Storer, worktree billy.Filesystem) *Repository { |
| 504 | return &Repository{ |
searching dependent graphs…