2024-12-02 05:14:52 -06:00
|
|
|
package forgepb
|
|
|
|
|
|
|
|
import (
|
2024-12-03 13:24:41 -06:00
|
|
|
"strings"
|
|
|
|
|
2024-12-02 05:14:52 -06:00
|
|
|
"go.wit.com/lib/protobuf/gitpb"
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-12-12 02:06:55 -06:00
|
|
|
// DOES NOT MODIFY ANYTHING
|
|
|
|
//
|
2024-12-02 05:14:52 -06:00
|
|
|
// this is a final check to make sure, before pushing
|
|
|
|
// a golang repo, that the go.sum file has the correct
|
|
|
|
// and current version of every package
|
|
|
|
//
|
|
|
|
// it re-scans the go.sum file. DOES NOT MODIFY ANYTHING
|
|
|
|
// this is the last thing to run to double check everything
|
|
|
|
// before 'git tag' or git push --tags
|
2024-12-02 08:45:27 -06:00
|
|
|
func (f *Forge) FinalGoDepsCheckOk(check *gitpb.Repo) bool {
|
2024-12-02 05:14:52 -06:00
|
|
|
var good bool = true
|
|
|
|
if check == nil {
|
|
|
|
log.Info("boo, check == nil")
|
|
|
|
return false
|
|
|
|
}
|
2024-12-15 15:52:46 -06:00
|
|
|
|
2024-12-18 20:09:03 -06:00
|
|
|
// parse the go.mod and go.sum files
|
|
|
|
if !check.ParseGoSum() {
|
|
|
|
log.Info("forge.FinalGoDepsCheckOk() failed")
|
2024-12-03 03:19:12 -06:00
|
|
|
return false
|
|
|
|
}
|
2024-12-02 05:14:52 -06:00
|
|
|
|
2024-12-18 20:09:03 -06:00
|
|
|
if check.GetGoPrimitive() {
|
2024-12-02 07:01:09 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-12-02 05:14:52 -06:00
|
|
|
log.Printf("current repo %s go dependancy count: %d", check.GetGoPath(), check.GoDepsLen())
|
|
|
|
deps := check.GoDeps.SortByGoPath()
|
|
|
|
for deps.Scan() {
|
|
|
|
depRepo := deps.Next()
|
2024-12-17 06:37:00 -06:00
|
|
|
found := f.FindByGoPath(depRepo.GetGoPath())
|
2024-12-02 05:14:52 -06:00
|
|
|
if found == nil {
|
2024-12-12 23:15:19 -06:00
|
|
|
if f.CheckOverride(depRepo.GetGoPath()) {
|
2024-12-03 13:24:41 -06:00
|
|
|
// skip this gopath because it's probably broken forever
|
|
|
|
continue
|
|
|
|
}
|
2024-12-02 05:14:52 -06:00
|
|
|
log.Info("not found:", depRepo.GetGoPath())
|
2024-12-03 13:24:41 -06:00
|
|
|
good = false
|
|
|
|
continue
|
2024-12-02 05:14:52 -06:00
|
|
|
}
|
|
|
|
// log.Info("found dep", depRepo.GetGoPath())
|
2024-12-02 07:01:09 -06:00
|
|
|
if depRepo.GetVersion() != found.GetTargetVersion() {
|
2024-12-17 06:37:00 -06:00
|
|
|
check := f.FindByGoPath(depRepo.GetGoPath())
|
|
|
|
if f.Config.IsReadOnly(check.GetGoPath()) {
|
2024-12-03 15:17:35 -06:00
|
|
|
log.Printf("%-48s ok error .%s. vs .%s. (ignoring read-only repo)", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
|
2024-12-02 05:14:52 -06:00
|
|
|
} else {
|
2024-12-12 23:15:19 -06:00
|
|
|
if f.CheckOverride(depRepo.GetGoPath()) {
|
|
|
|
log.Printf("%-48s ok error .%s. vs .%s. (forge.CheckOverride())", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
|
2024-12-03 13:24:41 -06:00
|
|
|
// skip this gopath because it's probably broken forever
|
|
|
|
continue
|
|
|
|
} else {
|
2024-12-03 15:17:35 -06:00
|
|
|
log.Printf("%-48s error %10s vs %10s", depRepo.GetGoPath(), depRepo.GetVersion(), found.GetTargetVersion())
|
2024-12-03 13:24:41 -06:00
|
|
|
good = false
|
|
|
|
}
|
2024-12-02 05:14:52 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return good
|
|
|
|
}
|
2024-12-03 13:24:41 -06:00
|
|
|
|
2024-12-12 23:15:19 -06:00
|
|
|
func (f *Forge) CheckOverride(gopath string) bool {
|
2024-12-03 13:24:41 -06:00
|
|
|
if gopath == "cloud.google.com/go" {
|
2024-12-12 23:15:19 -06:00
|
|
|
log.Info("CheckOverride() is ignoring", gopath)
|
2024-12-03 18:03:42 -06:00
|
|
|
return true
|
|
|
|
}
|
2024-12-03 23:04:04 -06:00
|
|
|
if gopath == "bou.ke/monkey" {
|
2024-12-12 23:15:19 -06:00
|
|
|
log.Info("CheckOverride() is ignoring", gopath)
|
2024-12-03 23:04:04 -06:00
|
|
|
return true
|
|
|
|
}
|
2024-12-03 18:03:42 -06:00
|
|
|
if gopath == "github.com/posener/complete/v2" {
|
2024-12-12 23:15:19 -06:00
|
|
|
log.Info("CheckOverride() is ignoring", gopath)
|
2024-12-03 18:03:42 -06:00
|
|
|
return true
|
2024-12-03 13:24:41 -06:00
|
|
|
}
|
|
|
|
if strings.HasPrefix(gopath, "github.com/go-gl") {
|
2024-12-12 23:15:19 -06:00
|
|
|
log.Info("CheckOverride() is ignoring", gopath)
|
2024-12-03 18:03:42 -06:00
|
|
|
return true
|
2024-12-03 13:24:41 -06:00
|
|
|
}
|
2024-12-03 18:03:42 -06:00
|
|
|
if strings.HasPrefix(gopath, "google.golang.org") {
|
2024-12-12 23:15:19 -06:00
|
|
|
log.Info("CheckOverride() is ignoring", gopath)
|
2024-12-03 18:03:42 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(gopath, "go.opencensus.io") {
|
2024-12-12 23:15:19 -06:00
|
|
|
log.Info("CheckOverride() is ignoring", gopath)
|
2024-12-03 18:03:42 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
if strings.HasPrefix(gopath, "github.com/nicksnyder/go-i18n") {
|
2024-12-12 23:15:19 -06:00
|
|
|
log.Info("CheckOverride() is ignoring", gopath)
|
2024-12-03 18:03:42 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
// fuckit for now. just blacklist github.com
|
|
|
|
if strings.HasPrefix(gopath, "github.com/") {
|
2024-12-12 23:15:19 -06:00
|
|
|
log.Info("CheckOverride() is ignoring", gopath)
|
2024-12-03 18:03:42 -06:00
|
|
|
return true
|
2024-12-03 15:17:35 -06:00
|
|
|
}
|
2024-12-03 13:24:41 -06:00
|
|
|
return false
|
|
|
|
}
|