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

Function PlainCloneContext

repository.go:479–501  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
479func 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
503func newRepository(s storage.Storer, worktree billy.Filesystem) *Repository {
504 return &Repository{

Calls 4

checkIfCleanupIsNeededFunction · 0.85
PlainInitFunction · 0.85
cleanUpDirFunction · 0.85
cloneMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…