6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-05 04:24:41 +00:00

Skip cloning a repo if target path already exists when getting a dump file

This commit is contained in:
Grzegorz Dlugoszewski
2020-06-30 10:23:10 +02:00
parent 28b24ec5ce
commit 7b9e74f903
2 changed files with 18 additions and 18 deletions

View File

@@ -35,11 +35,10 @@ type repo struct {
// CloneOpts specify detail about repository to clone.
type CloneOpts struct {
URL *url.URL
Path string // TODO: should Path be a part of clone opts?
Branch string
Quiet bool
IgnoreExisting bool
URL *url.URL
Path string // TODO: should Path be a part of clone opts?
Branch string
Quiet bool
}
// Open checks if given path can be accessed and returns a Repo instance pointing to it.
@@ -56,11 +55,6 @@ func Open(path string) (Repo, error) {
// Clone clones repository specified with CloneOpts.
func Clone(opts *CloneOpts) (Repo, error) {
// TODO: not sure if this check should be here
if opts.IgnoreExisting {
return nil, nil
}
runGit := run.Git("clone", opts.URL.String(), opts.Path)
if opts.Branch != "" {
runGit = run.Git("clone", "--branch", opts.Branch, "--single-branch", opts.URL.String(), opts.Path)