diff options
| author | Jeff Carr <[email protected]> | 2024-12-17 00:00:27 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-17 00:00:27 -0600 |
| commit | 075fce61e541eec6ccdc02c9de3bee14e9e486cf (patch) | |
| tree | a715cc0cc960c3d91d0be96e3006c6e8daf5597e /clone.go | |
| parent | a9286af8fd3f912aa357e3ebe67af09f42b8d534 (diff) | |
start cleaning up git interactions
Diffstat (limited to 'clone.go')
| -rw-r--r-- | clone.go | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -60,18 +60,17 @@ func clonePathHack(dirname string, basedir string, gopath string) (string, error // attempt to git clone if the go path doesn't exist // does a git clone, if it works, returns true -// workdir = /home/jcarr/go/src/ // gopath = go.wit.com/apps/helloworld func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) { var err error - pb, err := f.Repos.NewGoPath(f.goSrc, gopath, "") - if err == nil { - return f.finishClone(gopath, pb.URL) + fullpath := filepath.Join(f.goSrc, gopath) + + if pb := f.Repos.FindByFullPath(fullpath); pb != nil { + // repo already exists + return pb, nil } - workdir := f.goSrc - fullpath := filepath.Join(workdir, gopath) - dirname := filepath.Base(fullpath) + dirname := filepath.Base(fullpath) basedir := strings.TrimSuffix(fullpath, dirname) url := "https://" + gopath @@ -123,7 +122,7 @@ func (f *Forge) finishClone(gopath string, giturl string) (*gitpb.Repo, error) { var err error newr := f.Repos.FindByGoPath(gopath) if newr == nil { - newr, err = f.Repos.NewGoPath(f.goSrc, gopath, giturl) + newr, err = f.NewGoRepo(gopath, giturl) } if newr == nil { log.Warn("forge.Clone() new repo can not be found or created for gopath", gopath) |
