2024-11-20 09:31:24 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-11-20 10:31:25 -06:00
|
|
|
"os"
|
2024-11-20 09:31:24 -06:00
|
|
|
|
|
|
|
"go.wit.com/lib/protobuf/forgepb"
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-11-20 12:11:13 -06:00
|
|
|
// sent via ldflags
|
|
|
|
var VERSION string
|
|
|
|
|
2024-11-20 09:31:24 -06:00
|
|
|
func main() {
|
2024-11-28 18:36:15 -06:00
|
|
|
f := forgepb.Init()
|
2024-11-25 00:46:16 -06:00
|
|
|
|
2024-11-20 12:11:13 -06:00
|
|
|
if argv.List {
|
2024-11-28 08:35:39 -06:00
|
|
|
f.ConfigPrintTable()
|
2024-11-30 15:33:53 -06:00
|
|
|
loop := f.Config.SortByGoPath() // get the list of forge configs
|
2024-11-28 00:02:27 -06:00
|
|
|
for loop.Scan() {
|
|
|
|
r := loop.Next()
|
|
|
|
log.Info("repo:", r.GoPath)
|
|
|
|
}
|
2024-11-20 12:11:13 -06:00
|
|
|
os.Exit(0)
|
|
|
|
}
|
2024-11-20 23:51:28 -06:00
|
|
|
|
|
|
|
// try to delete, then save config and exit
|
|
|
|
if argv.Delete {
|
2024-11-29 13:27:32 -06:00
|
|
|
if oldr := f.Config.DeleteByGoPath(argv.GoPath); oldr == nil {
|
2024-11-20 23:51:28 -06:00
|
|
|
log.Info("deleted", argv.GoPath, "did not exist. did nothing")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
log.Info("deleted", argv.GoPath, "ok")
|
2024-11-28 00:02:27 -06:00
|
|
|
f.ConfigSave()
|
2024-11-20 23:51:28 -06:00
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
// try to update, then save config and exit
|
2024-11-20 13:43:26 -06:00
|
|
|
if argv.Update {
|
2024-11-20 21:22:05 -06:00
|
|
|
/*
|
2024-11-28 00:02:27 -06:00
|
|
|
if f.UpdateGoPath(argv.Name, argv.GoPath) {
|
2024-11-20 21:22:05 -06:00
|
|
|
// save updated config file
|
|
|
|
repos.ConfigSave()
|
|
|
|
}
|
|
|
|
*/
|
2024-11-20 13:43:26 -06:00
|
|
|
os.Exit(0)
|
|
|
|
}
|
2024-11-20 23:51:28 -06:00
|
|
|
|
|
|
|
// try to add, then save config and exit
|
2024-11-20 12:11:13 -06:00
|
|
|
if argv.Add {
|
2024-11-20 21:22:05 -06:00
|
|
|
log.Info("going to add a new repo", argv.GoPath)
|
2024-11-27 21:05:12 -06:00
|
|
|
new1 := forgepb.ForgeConfig{
|
2024-11-21 02:24:31 -06:00
|
|
|
GoPath: argv.GoPath,
|
|
|
|
Writable: argv.Writable,
|
|
|
|
ReadOnly: argv.ReadOnly,
|
2024-11-22 08:44:49 -06:00
|
|
|
Private: argv.Private,
|
2024-11-21 02:24:31 -06:00
|
|
|
Directory: argv.Directory,
|
|
|
|
Favorite: argv.Favorite,
|
|
|
|
Interesting: argv.Interesting,
|
|
|
|
}
|
|
|
|
|
2024-11-28 00:02:27 -06:00
|
|
|
if f.Config.Append(&new1) {
|
2024-11-20 21:22:05 -06:00
|
|
|
log.Info("added", new1.GoPath, "ok")
|
2024-11-20 12:11:13 -06:00
|
|
|
} else {
|
2024-11-20 21:22:05 -06:00
|
|
|
log.Info("added", new1.GoPath, "failed")
|
2024-11-20 12:11:13 -06:00
|
|
|
os.Exit(-1)
|
|
|
|
}
|
2024-11-28 00:02:27 -06:00
|
|
|
f.ConfigSave()
|
2024-11-20 12:11:13 -06:00
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2024-11-28 00:02:27 -06:00
|
|
|
// testMemoryCorruption(f)
|
|
|
|
f.ConfigSave()
|
2024-11-20 09:31:24 -06:00
|
|
|
}
|
|
|
|
|
2024-11-20 21:22:05 -06:00
|
|
|
/*
|
2024-11-20 13:56:27 -06:00
|
|
|
// this fucks shit up
|
|
|
|
func testMemoryCorruption(all *forgepb.Repos) *forgepb.Repos {
|
2024-11-20 09:31:24 -06:00
|
|
|
new1 := new(forgepb.Repo)
|
2024-11-20 13:56:27 -06:00
|
|
|
new1.Name = "bash1"
|
2024-11-20 09:31:24 -06:00
|
|
|
new1.Version = "5.2.21"
|
|
|
|
if all.Append(new1) {
|
|
|
|
log.Info("added", new1.Name, "ok")
|
|
|
|
} else {
|
|
|
|
log.Info("added", new1.Name, "failed")
|
|
|
|
}
|
|
|
|
|
2024-11-20 10:31:25 -06:00
|
|
|
new1 = new(forgepb.Repo)
|
2024-11-20 13:56:27 -06:00
|
|
|
new1.Name = "zookeeper1"
|
2024-11-20 10:31:25 -06:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
2024-11-20 09:31:24 -06:00
|
|
|
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)")
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("packages are:", len(all.Repos))
|
|
|
|
return all
|
|
|
|
}
|
2024-11-20 21:22:05 -06:00
|
|
|
*/
|