if go mod tidy fails, the package is special

This commit is contained in:
Jeff Carr 2025-01-30 04:26:00 -06:00
parent 114c77907a
commit 891017f2f9
1 changed files with 16 additions and 3 deletions

View File

@ -8,6 +8,8 @@ import (
)
func doStrict(repo *gitpb.Repo) error {
var err error
if !repo.IsValidDir() {
log.Info(repo.GetGoPath(), "is invalid. fix your repos.pb file with 'forge' first")
log.Info("")
@ -35,7 +37,7 @@ func doStrict(repo *gitpb.Repo) error {
return errors.New(repo.GetGoPath() + " not in the git master branch")
}
err := repo.RepoIgnoresGoMod()
err = repo.RepoIgnoresGoMod()
if err != nil {
log.Info(repo.GetGoPath(), "some wierd git error happened. investigate.", err)
return err
@ -57,11 +59,22 @@ func doStrict(repo *gitpb.Repo) error {
log.Info(repo.GetGoPath(), "GOING TO MAKE NEW go.* FILES")
// actually will re-create go.sum and go.mod now
if err := redoGoMod(repo); err != nil {
log.Info(repo.GetGoPath(), "redoGoMod() failed", err)
if _, err = repo.RunQuiet([]string{"go", "mod", "init", repo.GetGoPath()}); err != nil {
log.Warn("go mod init failed", err)
return err
}
if repo.Exists("go.mod") {
// well, if go mod init fails, then we will just error since 'go mod init' almost never fails
return err
}
if _, err := repo.RunQuiet([]string{"go", "mod", "tidy", "-go=" + golangVersion}); err == nil {
// I guess the thing to do, if go mod tidy fails, is to just leave the repo alone
// it's either primitive or could be a go support project but not in go
return nil
}
// the first time, it'll attempt to fix some stuff
cleanGoDepsCheckOk(repo)
// try to trim junk