46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
|
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
|
||
|
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")
|
||
|
|
||
|
// 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
|
||
|
}
|