6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-08 00:34:20 +00:00

Parse URL and create a repo dir inside CloneRepo function

This commit is contained in:
Grzegorz Dlugoszewski
2020-05-22 12:19:32 +02:00
parent 2bb6f06962
commit 2b622b99fe
4 changed files with 28 additions and 18 deletions

View File

@@ -14,7 +14,17 @@ type Repo struct {
Status *RepoStatus
}
func CloneRepo(url string, path string) error {
func CloneRepo(url string, repoRoot string) (path string, err error) {
repoPath, err := URLToPath(url)
if err != nil {
return path, err
}
path, err = MakeDir(repoRoot, repoPath)
if err != nil {
return path, err
}
options := &git.CloneOptions{
CheckoutOpts: nil,
FetchOptions: nil,
@@ -23,11 +33,11 @@ func CloneRepo(url string, path string) error {
RemoteCreateCallback: nil,
}
_, err := git.Clone(url, path, options)
_, err = git.Clone(url, path, options)
if err != nil {
return errors.Wrap(err, "Failed cloning repo")
return path, errors.Wrap(err, "Failed cloning repo")
}
return nil
return path, nil
}
func OpenRepo(path string) (*Repo, error) {