more things moved to gitpb
This commit is contained in:
parent
93e9e4e43b
commit
3a53e0bd9b
117
goConfig.go
117
goConfig.go
|
@ -6,69 +6,6 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
/*
|
||||
|
||||
// readGoMod reads and parses the go.sum file
|
||||
// saves the config information in *Repo.goConfig
|
||||
func (rs *RepoStatus) parseGoSum() (bool, error) {
|
||||
tmp := filepath.Join(rs.realPath.String(), "go.sum")
|
||||
gosum, err := os.Open(tmp)
|
||||
if err != nil {
|
||||
log.Log(REPO, "missing go.sum", rs.realPath.String())
|
||||
rs.goConfig = nil
|
||||
return false, err
|
||||
}
|
||||
defer gosum.Close()
|
||||
|
||||
var deps GoConfig
|
||||
deps = make(GoConfig)
|
||||
|
||||
scanner := bufio.NewScanner(gosum)
|
||||
log.Log(REPO, "gosum:", tmp)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
|
||||
parts := strings.Split(line, " ")
|
||||
if len(parts) == 3 {
|
||||
godep := strings.TrimSpace(parts[0])
|
||||
version := strings.TrimSpace(parts[1])
|
||||
if strings.HasSuffix(version, "/go.mod") {
|
||||
version = strings.TrimSuffix(version, "/go.mod")
|
||||
}
|
||||
currentversion, ok := deps[godep]
|
||||
if ok {
|
||||
// only use the first value found in the file?
|
||||
// this shouldn't have been possible. this function should
|
||||
// only be called from MakeRedomod()
|
||||
// todo: make go things a seperate package so this function
|
||||
// isn't exported?
|
||||
if version != currentversion {
|
||||
log.Log(REPOWARN, "\tgo.sum ", godep, "had both", version, currentversion)
|
||||
}
|
||||
} else {
|
||||
deps[godep] = version
|
||||
log.Log(REPO, "\t", godep, "=", version)
|
||||
}
|
||||
} else {
|
||||
// I've never seen this happen yet
|
||||
return false, errors.New("go.sum invalid: " + line)
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
rs.goConfig = nil
|
||||
return false, err
|
||||
}
|
||||
|
||||
rs.goConfig = deps
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (rs *RepoStatus) GoConfig() map[string]string {
|
||||
return rs.goConfig
|
||||
}
|
||||
*/
|
||||
|
||||
// for now, even check cmd.Exit
|
||||
func (rs *RepoStatus) strictRun(cmd []string) (bool, error) {
|
||||
r := rs.Run(cmd)
|
||||
|
@ -84,62 +21,10 @@ func (rs *RepoStatus) strictRun(cmd []string) (bool, error) {
|
|||
}
|
||||
|
||||
/*
|
||||
// poor name perhaps. It's because in most of these
|
||||
// repos you can also type "make redomod" to do the same thing
|
||||
// since it's a Makefile task that is also useful to be able to run
|
||||
// from the command line
|
||||
func (rs *RepoStatus) MakeRedomod() (bool, error) {
|
||||
if rs.ReadOnly() {
|
||||
log.Log(REPO, "will not go mod redo read only repos", rs.String())
|
||||
return false, errors.New(rs.GoPath() + " is read-only ")
|
||||
}
|
||||
|
||||
// unset the go development ENV var to generate release files
|
||||
os.Unsetenv("GO111MODULE")
|
||||
if ok, err := rs.strictRun([]string{"rm", "-f", "go.mod", "go.sum"}); !ok {
|
||||
log.Log(REPO, "rm go.mod go.sum failed", err)
|
||||
return ok, err
|
||||
}
|
||||
if ok, err := rs.strictRun([]string{"go", "mod", "init", rs.GoPath()}); !ok {
|
||||
log.Log(REPO, "go mod init failed", err)
|
||||
return ok, err
|
||||
}
|
||||
if ok, err := rs.strictRun([]string{"go", "mod", "tidy"}); !ok {
|
||||
log.Log(REPO, "go mod tidy failed", err)
|
||||
return ok, err
|
||||
}
|
||||
if ok, err := rs.strictRun([]string{"go", "mod", "edit", "-go=1.20"}); !ok {
|
||||
log.Log(REPO, "go mod edit failed", err)
|
||||
return ok, err
|
||||
}
|
||||
log.Log(REPO, "MakeRedomod() worked", rs.GoPath())
|
||||
|
||||
if rs.Exists("go.sum") {
|
||||
// return the attempt to parse go.mod & go.sum
|
||||
return rs.parseGoSum()
|
||||
}
|
||||
rs.goConfig = nil
|
||||
rs.primitive.SetText("false")
|
||||
|
||||
ok, err := rs.isPrimativeGoMod()
|
||||
if err != nil {
|
||||
// this means this repo does not depend on any other package
|
||||
log.Info("PRIMATIVE repo:", rs.String(), "err =", err)
|
||||
return false, err
|
||||
}
|
||||
if ok {
|
||||
// this means the repo is primitive so there is no go.sum
|
||||
rs.primitive.SetText("true")
|
||||
return true, nil
|
||||
}
|
||||
// this should never happen
|
||||
return false, errors.New("MakeRedomod() logic failed")
|
||||
}
|
||||
*/
|
||||
|
||||
func (rs *RepoStatus) IsReleased() bool {
|
||||
if rs.GetTargetVersion() == rs.GetCurrentVersion() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue