summaryrefslogtreecommitdiff
path: root/doStrict.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-15 22:34:20 -0600
committerJeff Carr <[email protected]>2024-12-15 22:34:20 -0600
commit3b714282df43c050920c16a47ee7b8ea46f4c350 (patch)
tree37bd03ae61030eec9faf4643631932c619098d23 /doStrict.go
parent6392687a6381ce8544b3e50d4083e1391e273849 (diff)
give up and make 3 different versions
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'doStrict.go')
-rw-r--r--doStrict.go84
1 files changed, 84 insertions, 0 deletions
diff --git a/doStrict.go b/doStrict.go
new file mode 100644
index 0000000..51a50d9
--- /dev/null
+++ b/doStrict.go
@@ -0,0 +1,84 @@
+package main
+
+import (
+ "errors"
+
+ "go.wit.com/lib/protobuf/gitpb"
+ "go.wit.com/log"
+)
+
+func doStrict(repo *gitpb.Repo) error {
+ if !repo.IsValid() {
+ log.Info(repo.GoPath, "is invalid. fix your repos.pb file with 'forge' first")
+ log.Info("")
+ log.Info("go install go.wit.com/apps/forge@latest")
+ log.Info("")
+ return errors.New(repo.GoPath + " is invalid. fix your repository list with 'forge' first")
+ }
+ log.Info(repo.GoPath, "is valid according to forge")
+
+ repo.Run([]string{"git", "notes", "remove"})
+
+ // erase the go.mod and go.sum files
+ eraseGoMod(repo)
+
+ if repo.GetMasterBranchName() != repo.GetCurrentBranchName() {
+ log.Info("")
+ log.Info("You are not operating on your git master branch.")
+ log.Info("Publishing go.mod & go.sum files must come from from git version tag on the master branch")
+ log.Info("")
+ return errors.New(repo.GoPath + " not in the git master branch")
+ }
+
+ err := repo.RepoIgnoresGoMod()
+ if err != nil {
+ log.Info(repo.GoPath, "some wierd git error happened. investigate.", err)
+ return err
+ }
+
+ if forge.Config.IsReadOnly(repo.GoPath) {
+ log.Info("you can not push to read only repositories.", repo.GoPath)
+ log.Info("change your .config/forge/ to indicate you own this repository")
+ return nil
+ }
+
+ if repo.CheckDirty() {
+ log.Info("")
+ log.Info("You can not continue on a dirty git repo.")
+ log.Info("")
+ return errors.New(repo.GoPath + " git repo is dirty")
+ }
+
+ log.Info(repo.GoPath, "GOING TO MAKE NEW go.* FILES")
+
+ // actually will re-create go.sum and go.mod now
+ if err := redoGoMod(repo); err != nil {
+ return err
+ }
+
+ // the first time, it'll attempt to fix some stuff
+ cleanGoDepsCheckOk(repo)
+ // try to trim junk
+ if err := trimGoSum(repo); err != nil {
+ return err
+ }
+ repo.ParseGoSum()
+
+ // check go.sum file
+ if err := cleanGoDepsCheckOk(repo); err != nil {
+ log.Info("forge.FinalGoDepsCheck() failed. boo. :", repo.GoPath)
+ return err
+ }
+
+ // put the files in the notes section in git
+ // this way, git commits are not messed up
+ // with this autogenerated code
+ if err := saveAsMetadata(repo); err != nil {
+ log.Info("save go.mod as git metadata failed", repo.GoPath, err)
+ return err
+ }
+
+ // everything worked!
+ configSave = true
+ return nil
+}