6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-10 10:14:25 +00:00

Refactor URL parsing so it's not being called twice

This commit is contained in:
Grzegorz Dlugoszewski
2020-05-22 15:53:44 +02:00
parent 2b622b99fe
commit a530b1506c
5 changed files with 52 additions and 44 deletions

View File

@@ -1,6 +1,7 @@
package pkg
import (
urlpkg "net/url"
"os"
"path"
@@ -14,11 +15,8 @@ type Repo struct {
Status *RepoStatus
}
func CloneRepo(url string, repoRoot string) (path string, err error) {
repoPath, err := URLToPath(url)
if err != nil {
return path, err
}
func CloneRepo(url *urlpkg.URL, repoRoot string) (path string, err error) {
repoPath := URLToPath(url)
path, err = MakeDir(repoRoot, repoPath)
if err != nil {
@@ -33,7 +31,7 @@ func CloneRepo(url string, repoRoot string) (path string, err error) {
RemoteCreateCallback: nil,
}
_, err = git.Clone(url, path, options)
_, err = git.Clone(url.String(), path, options)
if err != nil {
return path, errors.Wrap(err, "Failed cloning repo")
}