diff options
| author | Jeff Carr <[email protected]> | 2024-03-09 16:50:18 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-03-09 16:50:18 -0600 |
| commit | 7d3e4ce84e9414036c1783b5f262fb55439f0a34 (patch) | |
| tree | b6680c62f8e9dbbbb2552cf69edb96fb7084e9dd /new.go | |
| parent | 546ad6a842eba10ec9b1a028580c090cb06c6c29 (diff) | |
add submodules section of the .git/configv0.22.2
Diffstat (limited to 'new.go')
| -rw-r--r-- | new.go | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -84,7 +84,11 @@ func guessPaths(path string) (string, string, string, bool, error) { } if os.Getenv("REPO_AUTO_CLONE") == "true" { - clone(goSrcDir, path) + err := Clone(goSrcDir, path) + if err != nil { + // directory doesn't exist. exit with nil and error nil + return path, realpath, goSrcDir, false, errors.New("git clone") + } } if !IsDirectory(realpath) { @@ -105,7 +109,7 @@ func guessPaths(path string) (string, string, string, bool, error) { } // attempt to git clone if the go path doesn't exist -func clone(wdir string, path string) error { +func Clone(wdir string, path string) error { fullpath := filepath.Join(wdir, path) if IsDirectory(fullpath) { // directory already exists @@ -116,13 +120,14 @@ func clone(wdir string, path string) error { return err } - base := filepath.Join(wdir, filepath.Dir(path)) - os.MkdirAll(base, 0750) - err = os.Chdir(base) + fulldir := filepath.Join(wdir, filepath.Dir(path)) + base := filepath.Base(path) + os.MkdirAll(fulldir, 0750) + err = os.Chdir(fulldir) if err != nil { return err } - shell.RunPath(base, []string{"git", "clone", "http://" + path}) + shell.RunPath(fulldir, []string{"git", "clone", "http://" + path}) if IsDirectory(fullpath) { // clone worked return nil @@ -132,7 +137,7 @@ func clone(wdir string, path string) error { return err } log.Info("URL:", url) - shell.RunPath(base, []string{"git", "clone", url}) + shell.RunPath(fulldir, []string{"git", "clone", url, base}) if IsDirectory(fullpath) { // clone worked return nil @@ -174,7 +179,7 @@ func findGoImport(url string) (string, error) { } tmp := strings.TrimSpace(parts[0]) fields := strings.Split(tmp, " ") - log.Info("FIELDS:", fields) + // log.Info("FIELDS:", fields) if len(fields) == 3 { newurl = fields[2] break |
