go-mod-clean/doForce.go

46 lines
1.1 KiB
Go
Raw Normal View History

package main
import (
"errors"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
// this will make go.mod and go.sum files no matter what
// thsi will clean out everything and start over
func doForce(repo *gitpb.Repo) error {
// var perfect bool = true
2024-12-17 01:55:37 -06:00
if !repo.IsValidDir() {
2024-12-17 07:03:07 -06:00
log.Info(repo.GetGoPath(), "is invalid. fix your repos.pb file with 'forge' first")
log.Info("")
log.Info("go install go.wit.com/apps/forge@latest")
log.Info("")
2024-12-17 07:03:07 -06:00
return errors.New(repo.GetGoPath() + " is invalid. fix your repository list with 'forge' first")
}
2024-12-17 07:03:07 -06:00
log.Info(repo.GetGoPath(), "is valid according to forge")
// purge the git meta-data if --force
repo.Run([]string{"git", "notes", "remove"})
// erase the go.mod and go.sum files
eraseGoMod(repo)
// 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()
configSave = true
return nil
}