all of this code still sucks
This commit is contained in:
parent
5006d718fd
commit
01b332ceb8
Notes:
Jeff Carr
2024-12-15 15:56:13 -06:00
// `autogen:go.mod` module go.wit.com/lib/protobuf/gitpb go 1.21 toolchain go1.23.4 require ( github.com/destel/rill v0.6.0 github.com/go-cmd/cmd v1.4.3 go.wit.com/lib/gui/shell v0.22.17 go.wit.com/log v0.22.9 google.golang.org/protobuf v1.35.2 ) // `autogen:go.sum` github.com/destel/rill v0.6.0 h1:8MQRzS6k0akKmwNZFahKIhG1dkBeNxMoWKSfOxkaJNw= github.com/destel/rill v0.6.0/go.mod h1:srKuXzvGqINUEGYR5b/iwvW+L9/S35RxVHWGYbXNoO4= github.com/go-cmd/cmd v1.4.3 h1:6y3G+3UqPerXvPcXvj+5QNPHT02BUw7p6PsqRxLNA7Y= github.com/go-cmd/cmd v1.4.3/go.mod h1:u3hxg/ry+D5kwh8WvUkHLAMe2zQCaXd00t35WfQaOFk= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= go.wit.com/lib/gui/shell v0.22.17 h1:JfGozzkhrlCDCtQCVgVExobvseFc2ZIM9r76cXCouwg= go.wit.com/lib/gui/shell v0.22.17/go.mod h1:zduuMSWq+EE7w0xbXn+vkoGZ4HJhURVJpvXw8oK9WAU= go.wit.com/log v0.22.9 h1:aBM6SI2kxlJcBfS/osFTomJqNhO0hfEo1gk+LCqLk7Y= go.wit.com/log v0.22.9/go.mod h1:4uNPFBqhsAh8zNF+zxVEmC3c/9AZ8JeTfUUvRpddvLQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= // `autogen:`
|
@ -21,7 +21,7 @@ func (repo *Repo) ParseGoSum() (bool, error) {
|
|||
// check of the repo is a primative
|
||||
// that means, there is not a go.sum file
|
||||
// because the package is completely self contained!
|
||||
if ok, _ := repo.IsPrimitive(); ok {
|
||||
if err := repo.SetPrimitive(); err == nil {
|
||||
log.Info("This repo is primative!")
|
||||
return true, nil
|
||||
}
|
||||
|
|
|
@ -15,6 +15,13 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// deprecate use of IsPrimitive() to this function
|
||||
// this assumes go.mod and go.sum are in a releasable state
|
||||
func (repo *Repo) SetPrimitive() error {
|
||||
_, err := repo.IsPrimitive()
|
||||
return err
|
||||
}
|
||||
|
||||
// Detect a 'Primative' package. Sets the isPrimative flag
|
||||
// will return true if the repo is truly not dependent on _anything_ else
|
||||
// like spew or lib/widget
|
||||
|
@ -43,9 +50,9 @@ func (repo *Repo) IsPrimitive() (bool, error) {
|
|||
return false, errors.New("go.mod file is not primative")
|
||||
}
|
||||
if parts[0] == "go" {
|
||||
if parts[1] != "1.20" {
|
||||
log.Log(GITPBWARN, "go not set to 1.20 for", repo.GoPath)
|
||||
return false, errors.New("go not set to 1.20 for " + repo.GoPath)
|
||||
if parts[1] != "1.21" {
|
||||
log.Log(GITPBWARN, "go not set to 1.21 for", repo.GoPath)
|
||||
// return false, errors.New("go not set to 1.21 for " + repo.GoPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
31
isTracked.go
31
isTracked.go
|
@ -1,7 +1,10 @@
|
|||
package gitpb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (repo *Repo) isTracked(file string) (bool, error) {
|
||||
|
@ -30,34 +33,40 @@ func (repo *Repo) isIgnored(file string) (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
func (repo *Repo) RepoIgnoresGoMod() (bool, error) {
|
||||
// is it a good idea to run go-mod-clean in this repo?
|
||||
// for now, check if this repo should be ignored
|
||||
// TODO: go.mod and go.sum should be moved to git tag metadata
|
||||
func (repo *Repo) RepoIgnoresGoMod() error {
|
||||
file := "go.mod"
|
||||
if tracked, err := repo.isTracked(file); err != nil {
|
||||
fmt.Printf("%s Error checking if %s tracked: %v\n", repo.GoPath, file, err)
|
||||
return false, err
|
||||
msg := fmt.Sprintf("%s Error checking if %s tracked: %v\n", repo.GoPath, file, err)
|
||||
log.Info("gitpb:", msg)
|
||||
return err
|
||||
} else {
|
||||
if tracked {
|
||||
fmt.Printf("%s %s is tracked by Git.\n", repo.GoPath, file)
|
||||
return false, nil
|
||||
msg := fmt.Sprintf("%s %s is tracked by Git.\n", repo.GoPath, file)
|
||||
log.Info("gitpb:", msg)
|
||||
return errors.New(msg)
|
||||
}
|
||||
}
|
||||
|
||||
if ignored, err := repo.isIgnored(file); err != nil {
|
||||
if err != nil {
|
||||
fmt.Printf("%s Error checking if ignored: %v\n", repo.GoPath, err)
|
||||
return false, err
|
||||
msg := fmt.Sprintf("%s Error checking if ignored: %v\n", repo.GoPath, err)
|
||||
log.Info("gitpb:", msg)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
|
||||
if ignored {
|
||||
fmt.Printf("%s %s is ignored by Git.\n", repo.GoPath, file)
|
||||
return true, nil
|
||||
return nil
|
||||
}
|
||||
}
|
||||
fmt.Printf("%s %s is neither tracked nor ignored by Git.\n", repo.GoPath, file)
|
||||
msg := fmt.Sprintf("%s %s is neither tracked nor ignored by Git.\n", repo.GoPath, file)
|
||||
// this means, if you make a go.mod file, it'll add it to the repo to be tracked
|
||||
// so you need to either add it to .gitignore (this is what should happen)
|
||||
// or accept you want an auto-generated file to put endless garbage in your git repo
|
||||
// this obviously exposes my opinion on this subject matter
|
||||
return false, nil
|
||||
log.Info("gitpb:", msg)
|
||||
return errors.New(msg)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue