summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-30 04:26:00 -0600
committerJeff Carr <[email protected]>2025-01-30 04:26:00 -0600
commit891017f2f9fe286e5e08e73b920887e6c78c985f (patch)
tree9f119f7ab5c628184899710f3e1c4b93c6547606
parent114c77907a289d91871e8607775b8f64c5794bf6 (diff)
if go mod tidy fails, the package is special
-rw-r--r--doStrict.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/doStrict.go b/doStrict.go
index 9d233b9..59439d7 100644
--- a/doStrict.go
+++ b/doStrict.go
@@ -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