trying to fix clone
This commit is contained in:
parent
340872788e
commit
e3608b784e
Notes:
Jeff Carr
2024-12-15 12:29:37 -06:00
// `autogen:go.mod` module go.wit.com/lib/protobuf/forgepb go 1.21 toolchain go1.23.4 require ( github.com/destel/rill v0.6.0 go.wit.com/lib/gui/shell v0.22.17 go.wit.com/lib/protobuf/gitpb v0.0.30 go.wit.com/lib/protobuf/zoopb v0.0.19 go.wit.com/log v0.22.9 google.golang.org/protobuf v1.35.2 ) require github.com/go-cmd/cmd v1.4.3 // indirect // `autogen:go.sum` github.com/destel/rill v0.6.0 h1:8MQRzS6k0akKmwNZFahKIhG1dkBeNxMoWKSfOxkaJNw= github.com/destel/rill v0.6.0/go.mod h1:srKuXzvGqINUEGYR5b/iwvW+L9/S35RxVHWGYbXNoO4= github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y= github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= go.wit.com/lib/gui/shell v0.22.17 h1:JfGozzkhrlCDCtQCVgVExobvseFc2ZIM9r76cXCouwg= go.wit.com/lib/gui/shell v0.22.17/go.mod h1:zduuMSWq+EE7w0xbXn+vkoGZ4HJhURVJpvXw8oK9WAU= go.wit.com/lib/protobuf/gitpb v0.0.30 h1:ARgWw1EJewsSjG9uLfxK1dDckHXr47i72KsIORf3X8Y= go.wit.com/lib/protobuf/gitpb v0.0.30/go.mod h1:ufUa44/Y+0I5g+fX1nz995EEsKJ8apPpMtPTC3LXJu4= go.wit.com/lib/protobuf/zoopb v0.0.19 h1:sC5l0gs20adoV/zws7VEYlPhmgB77TvyzSK2XY2r5NI= go.wit.com/lib/protobuf/zoopb v0.0.19/go.mod h1:bdeHyuJI//suaWh97S0G2dBK46+e0gQk0u9nL3yfAcI= go.wit.com/log v0.22.9 h1:aBM6SI2kxlJcBfS/osFTomJqNhO0hfEo1gk+LCqLk7Y= go.wit.com/log v0.22.9/go.mod h1:4uNPFBqhsAh8zNF+zxVEmC3c/9AZ8JeTfUUvRpddvLQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= // `autogen:`
1
build.go
1
build.go
|
@ -47,6 +47,7 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
|
|||
if f.IsGoWork() {
|
||||
// there must be a valid go.mod file if compiling with go.work
|
||||
if err := repo.ValidGoSum(); err != nil {
|
||||
log.Warn("forge.doBuild() failed. run go-mod-clean here?")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
36
clone.go
36
clone.go
|
@ -66,7 +66,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) {
|
|||
var err error
|
||||
pb, err := f.Repos.NewGoPath(f.goSrc, gopath, "")
|
||||
if err == nil {
|
||||
return pb, err
|
||||
return f.finishClone(gopath, pb.URL)
|
||||
}
|
||||
workdir := f.goSrc
|
||||
fullpath := filepath.Join(workdir, gopath)
|
||||
|
@ -81,9 +81,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) {
|
|||
// try a direct git clone against the gopath
|
||||
// cloneActual("helloworld", "/home/jcarr/go/src/go.wit.com/apps", "https://go.wit.com/apps/helloworld")
|
||||
if finalurl, err := cloneActual(dirname, basedir, url); err == nil {
|
||||
f.Repos.DeleteByGoPath(gopath)
|
||||
// git clone worked!
|
||||
return f.Repos.NewGoPath(f.goSrc, gopath, finalurl)
|
||||
return f.finishClone(gopath, finalurl)
|
||||
}
|
||||
log.Info("direct attempt at git clone failed", url)
|
||||
|
||||
|
@ -95,9 +93,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) {
|
|||
log.Info("findGoImport() DID NOT WORK", err)
|
||||
} else {
|
||||
if finalurl, err := cloneActual(dirname, basedir, url); err == nil {
|
||||
f.Repos.DeleteByGoPath(gopath)
|
||||
// git clone worked!
|
||||
return f.Repos.NewGoPath(f.goSrc, gopath, finalurl)
|
||||
return f.finishClone(gopath, finalurl)
|
||||
}
|
||||
}
|
||||
log.Info("git clone from 'go-import' info failed", url)
|
||||
|
@ -108,9 +104,7 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) {
|
|||
log.Info("go list failed", err)
|
||||
} else {
|
||||
if finalurl, err := cloneActual(dirname, basedir, url); err == nil {
|
||||
f.Repos.DeleteByGoPath(gopath)
|
||||
// git clone worked!
|
||||
return f.Repos.NewGoPath(f.goSrc, gopath, finalurl)
|
||||
return f.finishClone(gopath, finalurl)
|
||||
}
|
||||
}
|
||||
log.Info("git clone from 'git list' info failed", url)
|
||||
|
@ -118,14 +112,30 @@ func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) {
|
|||
// try to parse a redirect
|
||||
|
||||
if finalurl, err := clonePathHack(dirname, basedir, gopath); err == nil {
|
||||
f.Repos.DeleteByGoPath(gopath)
|
||||
// WTF didn't go-import or go list work?
|
||||
return f.Repos.NewGoPath(f.goSrc, gopath, finalurl)
|
||||
return f.finishClone(gopath, finalurl)
|
||||
}
|
||||
|
||||
return nil, errors.New("can not find git sources for gopath " + gopath)
|
||||
}
|
||||
|
||||
// actually does something smart
|
||||
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)
|
||||
}
|
||||
if newr == nil {
|
||||
log.Warn("forge.Clone() new repo can not be found or created for gopath", gopath)
|
||||
return nil, err
|
||||
}
|
||||
if newr.URL != giturl {
|
||||
log.Warn("forge.Clone() url changed", newr.URL, "to", giturl)
|
||||
newr.URL = giturl
|
||||
}
|
||||
return newr, nil
|
||||
}
|
||||
|
||||
// newdir = helloworld
|
||||
// basedir = /home/jcarr/go/src/go.wit.com/apps
|
||||
// giturl = https://gitea.wit.com/gui/helloworld
|
||||
|
|
Loading…
Reference in New Issue