summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-17 07:03:07 -0600
committerJeff Carr <[email protected]>2024-12-17 07:03:07 -0600
commit62ad7e676cdb9c3618e74d9b0293718c083d6d62 (patch)
tree63493de7a12d21d7fb9244d4c7cd4263a7950fe1
parentc9f1624a72e1cf43dd32f878e56ff4e3c57ef5e6 (diff)
fixes for new gitpb
-rw-r--r--cleanGoSum.go8
-rw-r--r--doForce.go6
-rw-r--r--doSmart.go10
-rw-r--r--doStrict.go22
-rw-r--r--main.go14
-rw-r--r--redoGoMod.go14
6 files changed, 37 insertions, 37 deletions
diff --git a/cleanGoSum.go b/cleanGoSum.go
index d452e47..0cfba6e 100644
--- a/cleanGoSum.go
+++ b/cleanGoSum.go
@@ -23,7 +23,7 @@ func cleanGoDepsCheckOk(check *gitpb.Repo) error {
all := check.GoDeps.SortByGoPath()
for all.Scan() {
depRepo := all.Next()
- found := forge.Repos.FindByGoPath(depRepo.GetGoPath())
+ found := forge.Repos.FindByFullPath(depRepo.GetGoPath())
if found == nil {
if forge.CheckOverride(depRepo.GetGoPath()) {
// skip this gopath because it's probably broken forever
@@ -35,13 +35,13 @@ func cleanGoDepsCheckOk(check *gitpb.Repo) error {
}
// log.Info("found dep", depRepo.GetGoPath())
if depRepo.GetVersion() != found.GetMasterVersion() {
- check := forge.Repos.FindByGoPath(depRepo.GoPath)
+ check := forge.Repos.FindByFullPath(depRepo.GetGoPath())
var ends string
if check.CheckDirty() {
ends = "(dirty) "
}
- if forge.Config.IsReadOnly(check.GoPath) {
+ if forge.Config.IsReadOnly(check.GetGoPath()) {
ends += "(ignoring read-only) "
if argv.Verbose {
log.Printf("%-48s ok error .%s. vs .%s. %s", depRepo.GetGoPath(),
@@ -143,7 +143,7 @@ func trimGoSum(check *gitpb.Repo) error {
if good[gopath] {
fmt.Fprintf(newf, "%s %s\n", gopath, stuff[gopath])
fmt.Fprintf(newf, "%s %s\n", gopath, modver[gopath])
- check := forge.Repos.FindByGoPath(gopath)
+ check := forge.Repos.FindByFullPath(gopath)
if check == nil {
log.Info("gopath does not really exist:", gopath)
}
diff --git a/doForce.go b/doForce.go
index 9c9b58f..7dc326d 100644
--- a/doForce.go
+++ b/doForce.go
@@ -12,13 +12,13 @@ import (
func doForce(repo *gitpb.Repo) error {
// var perfect bool = true
if !repo.IsValidDir() {
- log.Info(repo.GoPath, "is invalid. fix your repos.pb file with 'forge' first")
+ 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("")
- return errors.New(repo.GoPath + " is invalid. fix your repository list with 'forge' first")
+ return errors.New(repo.GetGoPath() + " is invalid. fix your repository list with 'forge' first")
}
- log.Info(repo.GoPath, "is valid according to forge")
+ log.Info(repo.GetGoPath(), "is valid according to forge")
// purge the git meta-data if --force
repo.Run([]string{"git", "notes", "remove"})
diff --git a/doSmart.go b/doSmart.go
index f5588bf..af601a0 100644
--- a/doSmart.go
+++ b/doSmart.go
@@ -11,17 +11,17 @@ import (
// have the files in .gitignore for now
func doSmart(repo *gitpb.Repo) error {
if !repo.IsValidDir() {
- log.Info(repo.GoPath, "is invalid. fix your repos.pb file with 'forge' first")
+ 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("")
- return errors.New(repo.GoPath + " is invalid. fix your repository list with 'forge' first")
+ return errors.New(repo.GetGoPath() + " is invalid. fix your repository list with 'forge' first")
}
- log.Info(repo.GoPath, "is valid according to forge")
+ log.Info(repo.GetGoPath(), "is valid according to forge")
// if the repo has go.mod in the repo...
if err := repo.RepoIgnoresGoMod(); err != nil {
- log.Info("never modify go.mod or go.sum for this repo", repo.GoPath)
+ log.Info("never modify go.mod or go.sum for this repo", repo.GetGoPath())
log.Info("We recommend you add 'go.*' to your .gitignore file and store those files as git tag metadata")
repo.ParseGoSum()
return nil
@@ -33,7 +33,7 @@ func doSmart(repo *gitpb.Repo) error {
// try to restore from the git metadata
cname := repo.GetCurrentBranchName()
if err := repo.AutogenRestore(cname); err == nil {
- log.Info(repo.GoPath, "files were restored ok from git metadata (notes)")
+ log.Info(repo.GetGoPath(), "files were restored ok from git metadata (notes)")
configSave = true
return nil
}
diff --git a/doStrict.go b/doStrict.go
index 39192bd..f5e7cfa 100644
--- a/doStrict.go
+++ b/doStrict.go
@@ -9,13 +9,13 @@ import (
func doStrict(repo *gitpb.Repo) error {
if !repo.IsValidDir() {
- log.Info(repo.GoPath, "is invalid. fix your repos.pb file with 'forge' first")
+ 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("")
- return errors.New(repo.GoPath + " is invalid. fix your repository list with 'forge' first")
+ return errors.New(repo.GetGoPath() + " is invalid. fix your repository list with 'forge' first")
}
- log.Info(repo.GoPath, "is valid according to forge")
+ log.Info(repo.GetGoPath(), "is valid according to forge")
repo.Run([]string{"git", "notes", "remove"})
@@ -27,17 +27,17 @@ func doStrict(repo *gitpb.Repo) error {
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")
+ return errors.New(repo.GetGoPath() + " not in the git master branch")
}
err := repo.RepoIgnoresGoMod()
if err != nil {
- log.Info(repo.GoPath, "some wierd git error happened. investigate.", err)
+ log.Info(repo.GetGoPath(), "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)
+ if forge.Config.IsReadOnly(repo.GetGoPath()) {
+ log.Info("you can not push to read only repositories.", repo.GetGoPath())
log.Info("change your .config/forge/ to indicate you own this repository")
return nil
}
@@ -46,10 +46,10 @@ func doStrict(repo *gitpb.Repo) error {
log.Info("")
log.Info("You can not continue on a dirty git repo.")
log.Info("")
- return errors.New(repo.GoPath + " git repo is dirty")
+ return errors.New(repo.GetGoPath() + " git repo is dirty")
}
- log.Info(repo.GoPath, "GOING TO MAKE NEW go.* FILES")
+ log.Info(repo.GetGoPath(), "GOING TO MAKE NEW go.* FILES")
// actually will re-create go.sum and go.mod now
if err := redoGoMod(repo); err != nil {
@@ -66,7 +66,7 @@ func doStrict(repo *gitpb.Repo) error {
// check go.sum file
if err := cleanGoDepsCheckOk(repo); err != nil {
- log.Info("forge.FinalGoDepsCheck() failed. boo. :", repo.GoPath)
+ log.Info("forge.FinalGoDepsCheck() failed. boo. :", repo.GetGoPath())
return err
}
@@ -74,7 +74,7 @@ func doStrict(repo *gitpb.Repo) error {
// 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)
+ log.Info("save go.mod as git metadata failed", repo.GetGoPath(), err)
return err
}
diff --git a/main.go b/main.go
index d777042..5878b37 100644
--- a/main.go
+++ b/main.go
@@ -34,7 +34,7 @@ func main() {
if argv.All {
// run this on every single repo
// do this before publishing new golang versions
- all := forge.Repos.SortByGoPath()
+ all := forge.Repos.SortByFullPath()
for all.Scan() {
check = all.Next()
if err := doMain(check); err != nil {
@@ -67,7 +67,7 @@ func main() {
forge.ConfigSave()
}
- log.Info("forge.FinalGoDepsCheck() worked :", check.GoPath)
+ log.Info("forge.FinalGoDepsCheck() worked :", check.GetGoPath())
okExit(check, "go.sum seems clean")
}
@@ -80,9 +80,9 @@ func findPwdRepo() *gitpb.Repo {
gopath := strings.TrimPrefix(pwd, forge.GetGoSrc())
gopath = strings.Trim(gopath, "/")
log.Info("findRepo() trying gopath", gopath)
- check = forge.Repos.FindByGoPath(gopath)
+ check = forge.Repos.FindByFullPath(gopath)
if check != nil {
- log.Info("findRepo() worked", check.GoPath)
+ log.Info("findRepo() worked", check.GetGoPath())
return check
}
}
@@ -91,7 +91,7 @@ func findPwdRepo() *gitpb.Repo {
func saveAsMetadata(repo *gitpb.Repo) error {
cname := repo.GetCurrentBranchName()
- if repo.GoPrimitive {
+ if repo.GoInfo.GoPrimitive {
if err := repo.AutogenSave([]string{"go.mod"}, cname, true); err != nil {
return err
}
@@ -112,7 +112,7 @@ func restoreFromGoPkg(repo *gitpb.Repo) error {
if rver == "" {
return errors.New("could not get master version")
}
- modfile := filepath.Join(homedir, "go/pkg/mod", repo.GoPath+"@"+rver, "go.mod")
+ modfile := filepath.Join(homedir, "go/pkg/mod", repo.GetGoPath()+"@"+rver, "go.mod")
log.Info("mod path should be", modfile)
data, err := os.ReadFile(modfile)
if err != nil {
@@ -125,7 +125,7 @@ func restoreFromGoPkg(repo *gitpb.Repo) error {
defer modf.Close()
modf.Write(data)
- modfile = filepath.Join(homedir, "go/pkg/mod", repo.GoPath+"@"+rver, "go.sum")
+ modfile = filepath.Join(homedir, "go/pkg/mod", repo.GetGoPath()+"@"+rver, "go.sum")
log.Info("mod path should be", modfile)
data, err = os.ReadFile(modfile)
if err == nil {
diff --git a/redoGoMod.go b/redoGoMod.go
index d74addd..f9b8fb5 100644
--- a/redoGoMod.go
+++ b/redoGoMod.go
@@ -15,7 +15,7 @@ import (
func eraseGoMod(repo *gitpb.Repo) {
// unset the go development ENV var to generate release files
if err := repo.StrictRun([]string{"rm", "-f", "go.mod", "go.sum"}); err != nil {
- log.Warn(repo.GoPath, "rm go.mod go.sum failed", err)
+ log.Warn(repo.GetGoPath(), "rm go.mod go.sum failed", err)
}
}
@@ -23,7 +23,7 @@ func eraseGoMod(repo *gitpb.Repo) {
func setGoVersion(repo *gitpb.Repo, version string) error {
// most things should build with golang after 1.21
if err := repo.StrictRun([]string{"go", "mod", "edit", "-go=" + version}); err != nil {
- log.Warn(repo.GoPath, "go mod edit failed", err)
+ log.Warn(repo.GetGoPath(), "go mod edit failed", err)
return err
}
return nil
@@ -37,7 +37,7 @@ func redoGoMod(repo *gitpb.Repo) error {
log.Warn("rm go.mod go.sum failed", err)
return err
}
- if err := repo.StrictRun([]string{"go", "mod", "init", repo.GoPath}); err != nil {
+ if err := repo.StrictRun([]string{"go", "mod", "init", repo.GetGoPath()}); err != nil {
log.Warn("go mod init failed", err)
return err
}
@@ -48,12 +48,12 @@ func redoGoMod(repo *gitpb.Repo) error {
// most things should build with golang after 1.21 // todo: allow this to be set somewhere
if err := setGoVersion(repo, "1.21"); err != nil {
- log.Warn(repo.GoPath, "go mod edit failed", err)
+ log.Warn(repo.GetGoPath(), "go mod edit failed", err)
return err
}
repo.GoDeps = nil
- repo.GoPrimitive = false
+ repo.GoInfo.GoPrimitive = false
// if there is not a go.sum file, it better be a primitive golang project
if !repo.Exists("go.sum") {
@@ -61,13 +61,13 @@ func redoGoMod(repo *gitpb.Repo) error {
ok, err := repo.IsPrimitive()
if err != nil {
// this means this repo does not depend on any other package
- log.Info("PRIMATIVE repo error:", repo.GoPath, "err =", err)
+ log.Info("PRIMATIVE repo error:", repo.GetGoPath(), "err =", err)
return err
}
if ok {
// this means the repo is primitive so there is no go.sum
- repo.GoPrimitive = true
+ repo.GoInfo.GoPrimitive = true
repo.GoDeps = new(gitpb.GoDeps)
return nil
}