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

Function PlainCloneContext

repository.go:472–494  ·  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

470// TODO(mcuadros): move isBare to CloneOptions in v5
471// TODO(smola): refuse upfront to clone on a non-empty directory in v5, see #1027
472func PlainCloneContext(ctx context.Context, path string, isBare bool, o *CloneOptions) (*Repository, error) {
473 cleanup, cleanupParent, err := checkIfCleanupIsNeeded(path)
474 if err != nil {
475 return nil, err
476 }
477
478 if o.Mirror {
479 isBare = true
480 }
481 r, err := PlainInit(path, isBare)
482 if err != nil {
483 return nil, err
484 }
485
486 err = r.clone(ctx, o)
487 if err != nil && err != ErrRepositoryAlreadyExists {
488 if cleanup {
489 _ = cleanUpDir(path, cleanupParent)
490 }
491 }
492
493 return r, err
494}
495
496func newRepository(s storage.Storer, worktree billy.Filesystem) *Repository {
497 return &Repository{

Calls 4

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