better download app checks

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-27 14:40:17 -06:00
parent 317a941e01
commit 7b34a318e5
2 changed files with 35 additions and 9 deletions

View File

@ -40,7 +40,10 @@ func quickCmd(fullpath string, cmd []string) bool {
err, b, output = repostatus.RunCmd(fullpath, cmd)
if err != nil {
log.Error(err)
log.Warn("cmd =", cmd)
log.Warn("err =", err)
log.Warn("b =", b)
log.Warn("output =", string(output))
return false
} else if !b {
log.Warn("b =", b)

View File

@ -85,6 +85,27 @@ func listWindow() {
// lw.Toggle()
}
func downloadRepo(path string) bool {
log.Info("downloading", path, "here")
os.Setenv("GO111MODULE", "off")
goSrcDir := me.goSrcPwd.String()
if ! quickCmd(goSrcDir, []string{"go", "get", "-v", path}) {
log.Info("go get failed")
return false
}
fullpath := filepath.Join(goSrcDir, path)
if ! quickCmd(fullpath, []string{"go", "get", "-v", "-u", "."}) {
log.Info("go get depends failed")
return false
}
if me.autoDryRun.Checked() {
return false
}
return true
}
func (s *section) add(path string) {
if s == nil {
return
@ -94,14 +115,16 @@ func (s *section) add(path string) {
tmp.path = s.grid.NewLabel(path)
tmp.downloadB = s.grid.NewButton("download", func() {
lw.Disable()
log.Info("downloading", tmp.path.String(), "here")
os.Setenv("GO111MODULE", "off")
goSrcDir := me.goSrcPwd.String()
quickCmd(goSrcDir, []string{"go", "get", "-v", tmp.path.String()})
fullpath := filepath.Join(goSrcDir, tmp.path.String())
quickCmd(fullpath, []string{"go", "get", "-v", "-u", "."})
if me.autoDryRun.Checked() {
tmp.downloadB.SetLabel("uncheck --dry-run")
}
if downloadRepo(tmp.path.String()) {
log.Info("download", tmp.path.String(), "worked")
tmp.downloadB.SetLabel("downloaded")
tmp.downloadB.Disable()
} else {
log.Info("download", tmp.path.String(), "failed")
}
lw.Enable()
})
if repostatus.VerifyLocalGoRepo(path) {