package main import ( "os" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/log" ) // sent via ldflags var VERSION string func main() { var repos *forgepb.Repos repos = new(forgepb.Repos) if err := repos.ConfigLoad(); err != nil { log.Warn("forgepb.ConfigLoad() failed", err) os.Exit(-1) } if argv.List { log.Info(forgepb.RepoHeader()) loop := repos.SortByPath() // get the list of repos for loop.Scan() { r := loop.Repo() log.Info("repo:", r.GoPath) } os.Exit(0) } // try to delete, then save config and exit if argv.Delete { if oldr := repos.DeleteByPath(argv.GoPath); oldr == nil { log.Info("deleted", argv.GoPath, "did not exist. did nothing") os.Exit(0) } log.Info("deleted", argv.GoPath, "ok") repos.ConfigSave() os.Exit(0) } // try to update, then save config and exit if argv.Update { /* if repos.UpdateGoPath(argv.Name, argv.GoPath) { // save updated config file repos.ConfigSave() } */ os.Exit(0) } // try to add, then save config and exit if argv.Add { log.Info("going to add a new repo", argv.GoPath) new1 := new(forgepb.Repo) new1.GoPath = argv.GoPath new1.Writable = argv.Writable new1.ReadOnly = argv.ReadOnly new1.Directory = argv.Directory if repos.Append(new1) { log.Info("added", new1.GoPath, "ok") } else { log.Info("added", new1.GoPath, "failed") os.Exit(-1) } repos.ConfigSave() os.Exit(0) } // testMemoryCorruption(repos) repos.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)") } fmt.Println("packages are:", len(all.Repos)) return all } */