smarter checking
This commit is contained in:
parent
66dc174bba
commit
cb78bb02b8
16
restore.go
16
restore.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -14,11 +15,26 @@ func restoreFromGoPkg(repo *gitpb.Repo) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
badExit(nil, err)
|
badExit(nil, err)
|
||||||
}
|
}
|
||||||
|
repo.RunVerboseOnError([]string{"rm", "-f", "go.mod", "go.sum"})
|
||||||
rver := repo.GetLastTag()
|
rver := repo.GetLastTag()
|
||||||
if rver == "" {
|
if rver == "" {
|
||||||
return errors.New("could not get master version")
|
return errors.New("could not get master version")
|
||||||
}
|
}
|
||||||
|
goget := repo.GetGoPath() + "@" + rver
|
||||||
|
moddir := filepath.Join(homedir, "go/pkg/mod", repo.GetGoPath()+"@"+rver)
|
||||||
|
if shell.IsDir(moddir) {
|
||||||
|
// things are ok
|
||||||
|
} else {
|
||||||
|
return errors.New("must run go get " + goget)
|
||||||
|
}
|
||||||
|
|
||||||
modfile := filepath.Join(homedir, "go/pkg/mod", repo.GetGoPath()+"@"+rver, "go.mod")
|
modfile := filepath.Join(homedir, "go/pkg/mod", repo.GetGoPath()+"@"+rver, "go.mod")
|
||||||
|
if shell.Exists(modfile) {
|
||||||
|
// go.mod exists
|
||||||
|
} else {
|
||||||
|
// nothing to do. this repo does not have a go.mod file
|
||||||
|
return nil
|
||||||
|
}
|
||||||
log.Info("mod path should be", modfile)
|
log.Info("mod path should be", modfile)
|
||||||
data, err := os.ReadFile(modfile)
|
data, err := os.ReadFile(modfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue