mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-21 22:05:17 +02:00
before: gitrepo vs git packages after: git package fully handle all git operations by the way, use `WithRepo(repo)` instead of `WithDir(repo.Path)` to hide path details. benefits: 1. remove all unnecessary wrappers, developers no need to struggle with "which package should be used" 2. simplify code, RepositoryFacade can (will) be used everywhere, all "path" details are (will be) hidden
25 lines
886 B
Go
25 lines
886 B
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package git
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.dev/modules/git/gitcmd"
|
|
)
|
|
|
|
// CloneExternalRepo clones an external repository to the managed repository.
|
|
func CloneExternalRepo(ctx context.Context, fromRemoteURL string, toRepo RepositoryFacade, opts CloneRepoOptions) error {
|
|
return Clone(ctx, fromRemoteURL, gitcmd.RepoLocalPath(toRepo), opts)
|
|
}
|
|
|
|
// CloneRepoToLocal clones a managed repository to a local path.
|
|
func CloneRepoToLocal(ctx context.Context, fromRepo RepositoryFacade, toLocalPath string, opts CloneRepoOptions) error {
|
|
return Clone(ctx, gitcmd.RepoLocalPath(fromRepo), toLocalPath, opts)
|
|
}
|
|
|
|
func CloneManaged(ctx context.Context, fromRepo, toRepo RepositoryFacade, opts CloneRepoOptions) error {
|
|
return Clone(ctx, gitcmd.RepoLocalPath(fromRepo), gitcmd.RepoLocalPath(toRepo), opts)
|
|
}
|