start cleaning up git interactions
This commit is contained in:
parent
a9286af8fd
commit
075fce61e5
17
clone.go
17
clone.go
|
@ -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)
|
||||
}
|
||||
workdir := f.goSrc
|
||||
fullpath := filepath.Join(workdir, gopath)
|
||||
dirname := filepath.Base(fullpath)
|
||||
fullpath := filepath.Join(f.goSrc, gopath)
|
||||
|
||||
if pb := f.Repos.FindByFullPath(fullpath); pb != nil {
|
||||
// repo already exists
|
||||
return pb, nil
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -68,6 +68,9 @@ func gitDirectoriesNew(srcDir string) ([]string, error) {
|
|||
case "go.work.last":
|
||||
default:
|
||||
// todo: figure out a way to do padding for init()
|
||||
if trip == false {
|
||||
log.Info("WARNING:")
|
||||
}
|
||||
log.Info("WARNING: you have an untracked file outside of any .git repository:", path)
|
||||
trip = true
|
||||
}
|
||||
|
@ -141,7 +144,7 @@ func (f *Forge) rillScanDirs(gopaths []string) (int, error) {
|
|||
// Read users from the API.
|
||||
// Concurrency = 20
|
||||
dirs := rill.Map(ids, 20, func(id string) (*gitpb.Repo, error) {
|
||||
return f.NewGoPathRepo(id)
|
||||
return f.NewGoRepo(id, "")
|
||||
})
|
||||
|
||||
var counter int
|
||||
|
|
|
@ -3,19 +3,22 @@ package forgepb
|
|||
import (
|
||||
"fmt"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (f *Forge) NewGoPathRepo(gopath string) (*gitpb.Repo, error) {
|
||||
repo, err := f.Repos.NewGoPath(f.GetGoSrc(), gopath, "")
|
||||
func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) {
|
||||
fullpath := filepath.Join(f.GetGoSrc(), gopath)
|
||||
repo, err := f.Repos.NewGoRepo(fullpath, gopath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
repo.URL = url
|
||||
f.VerifyBranchNames(repo)
|
||||
repo.ParseGoSum()
|
||||
repo.Reload()
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue