summaryrefslogtreecommitdiff
path: root/forgeConfig/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-05 18:40:31 -0600
committerJeff Carr <[email protected]>2025-01-05 18:40:31 -0600
commit98b0d445bc513c5439421d1ec0d32874fc1350f9 (patch)
tree2905bb2369bb91b4bf58c78c6ddcdb6fcf5cbf00 /forgeConfig/main.go
parentcff4af7935de4bcbb48f9b8b4c028be7e4e5e890 (diff)
allow setting 'master' and 'devel' branchesv0.0.18
Diffstat (limited to 'forgeConfig/main.go')
-rw-r--r--forgeConfig/main.go111
1 files changed, 35 insertions, 76 deletions
diff --git a/forgeConfig/main.go b/forgeConfig/main.go
index 36b0b71..d6fabba 100644
--- a/forgeConfig/main.go
+++ b/forgeConfig/main.go
@@ -11,26 +11,29 @@ import (
var VERSION string
func main() {
- f := forgepb.Init()
+ var f *forgepb.Forge
+ f = forgepb.Init()
if argv.List {
f.ConfigPrintTable()
- loop := f.Config.SortByGoPath() // get the list of forge configs
- for loop.Scan() {
- r := loop.Next()
- log.Info("repo:", r.GoPath)
- }
+ /*
+ loop := f.Config.SortByGoPath() // get the list of forge configs
+ for loop.Scan() {
+ r := loop.Next()
+ log.Info("repo:", r.GoPath)
+ }
+ */
os.Exit(0)
}
// try to delete, then save config and exit
if argv.Delete {
- if f.Config.DeleteByGoPath(argv.GoPath) {
- log.Info("deleted", argv.GoPath, "did not exist. did nothing")
+ if deleteGoPath(f, argv.GoPath) {
+ log.Info("deleted", argv.GoPath, "ok")
+ f.ConfigSave()
os.Exit(0)
}
- log.Info("deleted", argv.GoPath, "ok")
- f.ConfigSave()
+ log.Info("deleted", argv.GoPath, "did not exist. did nothing")
os.Exit(0)
}
@@ -48,14 +51,18 @@ func main() {
// try to add, then save config and exit
if argv.Add {
log.Info("going to add a new repo", argv.GoPath)
+ deleteGoPath(f, argv.GoPath)
new1 := forgepb.ForgeConfig{
- GoPath: argv.GoPath,
- Writable: argv.Writable,
- ReadOnly: argv.ReadOnly,
- Private: argv.Private,
- Directory: argv.Directory,
- Favorite: argv.Favorite,
- Interesting: argv.Interesting,
+ GoPath: argv.GoPath,
+ Writable: argv.Writable,
+ ReadOnly: argv.ReadOnly,
+ Private: argv.Private,
+ Directory: argv.Directory,
+ Favorite: argv.Favorite,
+ Interesting: argv.Interesting,
+ MasterBranchName: argv.Master,
+ DevelBranchName: argv.Devel,
+ UserBranchName: argv.User,
}
if f.Config.Append(&new1) {
@@ -68,66 +75,18 @@ func main() {
os.Exit(0)
}
- // testMemoryCorruption(f)
- f.ConfigSave()
}
-/*
-// this fucks shit up
-func testMemoryCorruption(all *forgepb.Repos) *forgepb.Repos {
- new1 := new(forgepb.Repo)
- new1.Name = "bash1"
- new1.Version = "5.2.21"
- if all.Append(new1) {
- log.Info("added", new1.Name, "ok")
- } else {
- log.Info("added", new1.Name, "failed")
- }
-
- new1 = new(forgepb.Repo)
- new1.Name = "zookeeper1"
- new1.Debname = "zookeeper-go"
- if all.Append(new1) {
- log.Info("added", new1.Name, "ok")
- } else {
- log.Info("added", new1.Name, "failed")
- }
-
- new1 = new(forgepb.Repo)
- new1.Name = "wit-package"
- new1.Private = true
- if all.Append(new1) {
- log.Info("added", new1.Name, "ok")
- } else {
- log.Info("added", new1.Name, "failed")
- }
-
- new1 = new(forgepb.Repo)
- new1.Name = "networkQuality"
- new1.Debname = "networkquality"
- new1.Readonly = true
- if all.Append(new1) {
- log.Info("added", new1.Name, "ok")
- } else {
- log.Info("added", new1.Name, "failed")
- }
-
- new2 := new(forgepb.Repo)
- new2.Name = "go-clone"
- new2.Version = "0.6.8" // good version of the macos
- if all.Append(new2) {
- log.Info("added", new2.Name, "ok")
- } else {
- log.Info("added", new2.Name, "failed")
- }
-
- if all.Append(new2) {
- log.Info("added", new2.Name, "ok (this is bad)")
- } else {
- log.Info("added", new2.Name, "failed (but ok)")
+func deleteGoPath(f *forgepb.Forge, gopath string) bool {
+ var deleted bool = false
+ for {
+ if f.Config.DeleteByGoPath(gopath) {
+ log.Info("deleted ok", gopath)
+ deleted = true
+ } else {
+ log.Info("did not delete", gopath)
+ break
+ }
}
-
- fmt.Println("packages are:", len(all.Repos))
- return all
+ return deleted
}
-*/