2024-02-20 06:53:42 -06:00
|
|
|
package repolist
|
|
|
|
|
|
|
|
// does processing on the go.mod and go.sum files
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// scans through everything in the go.sum file to make
|
|
|
|
// sure the versions are correct when attempting to do a GUI release
|
2024-02-23 09:02:51 -06:00
|
|
|
func (rl *RepoList) CheckValidGoSum(r *RepoRow) (bool, error) {
|
2024-02-20 06:53:42 -06:00
|
|
|
log.Log(REPOWARN, "CheckValidGoSum() started")
|
|
|
|
ok, err := r.Status.MakeRedomod()
|
|
|
|
if !ok {
|
2024-02-20 18:55:50 -06:00
|
|
|
log.Log(REPOWARN, "CheckValidGoSum() MakeRedomod() failed", err)
|
2024-02-20 06:53:42 -06:00
|
|
|
return ok, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// go through each go.sum dependancy to see if the package is released
|
|
|
|
for depPath, version := range r.Status.GoConfig() {
|
|
|
|
log.Log(REPO, " ", depPath, version)
|
|
|
|
|
|
|
|
// lookup the repo
|
|
|
|
deprs := rl.FindRepo(depPath)
|
|
|
|
if deprs == nil {
|
|
|
|
// well, the go.sum dependancy hasn't been processed or doesn't exist
|
|
|
|
// so, download it? ignore it?
|
|
|
|
// for now, if it's not one of the GUI repos, assume it's readonly and ignore it
|
|
|
|
if strings.HasPrefix(depPath, "go.wit.com") {
|
|
|
|
log.Log(REPOWARN, "Run: go get -v", depPath)
|
|
|
|
// rs.RunCmd([]string{"go", "get", "-v", depname}) // download this here?
|
|
|
|
return false, errors.New("CheckValidGoSum() download repo: " + depPath)
|
|
|
|
}
|
|
|
|
// it's probably okay. running a compile check before this would be a good test
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if deprs.ReadOnly() {
|
|
|
|
// ignore versioning on other repos. todo: help fix this situation somehow?
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if deprs.CheckDirty() {
|
|
|
|
return false, errors.New("CheckValidGoSum() depends on dirty repo " + deprs.GoPath())
|
|
|
|
}
|
|
|
|
currentV := deprs.Status.GetCurrentVersion()
|
|
|
|
targetV := deprs.Status.GetTargetVersion()
|
|
|
|
if currentV != targetV {
|
|
|
|
return false, errors.New("CheckValidGoSum() depends on yet unreleased repo " + deprs.GoPath())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// no dependancies error'd out. It should be ok to release this package
|
2024-02-20 16:13:18 -06:00
|
|
|
log.Log(REPOWARN, "Releasing this should be ok", r.GoPath())
|
2024-02-20 06:53:42 -06:00
|
|
|
return true, nil
|
|
|
|
}
|