2024-11-20 09:31:24 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
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-20 10:31:25 -06:00
|
|
|
var repos *forgepb.Repos
|
|
|
|
repos = new(forgepb.Repos)
|
|
|
|
if err := repos.ConfigLoad(); err != nil {
|
|
|
|
log.Warn("forgepb.ConfigLoad() failed", err)
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
2024-11-20 12:11:13 -06:00
|
|
|
if argv.List {
|
|
|
|
log.Info(forgepb.RepoHeader())
|
2024-11-20 13:43:26 -06:00
|
|
|
loop := repos.SortByName() // get the list of repos
|
2024-11-20 12:11:13 -06:00
|
|
|
for loop.Scan() {
|
|
|
|
r := loop.Repo()
|
|
|
|
log.Info("repo:", r.Name, r.Gopath)
|
|
|
|
}
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
2024-11-20 13:43:26 -06:00
|
|
|
if argv.Update {
|
|
|
|
r := repos.FindByName(argv.Name) // find the repo
|
|
|
|
if r == nil {
|
|
|
|
log.Info("rep:", argv.Name, "not found")
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
|
|
|
r.Gopath = argv.GoPath
|
|
|
|
repos.ConfigSave()
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
2024-11-20 12:11:13 -06:00
|
|
|
if argv.Add {
|
|
|
|
log.Info("going to add a new repo", argv.Name, argv.GoPath)
|
|
|
|
new1 := new(forgepb.Repo)
|
|
|
|
new1.Name = argv.Name
|
|
|
|
new1.Gopath = argv.GoPath
|
|
|
|
if repos.Append(new1) {
|
|
|
|
log.Info("added", new1.Name, "ok")
|
|
|
|
} else {
|
|
|
|
log.Info("added", new1.Name, "failed")
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
|
|
|
repos.ConfigSave()
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2024-11-20 10:31:25 -06:00
|
|
|
testAddRepos(repos)
|
2024-11-20 09:31:24 -06:00
|
|
|
repos.ConfigSave()
|
|
|
|
}
|
|
|
|
|
2024-11-20 10:31:25 -06:00
|
|
|
func testAddRepos(all *forgepb.Repos) *forgepb.Repos {
|
2024-11-20 09:31:24 -06:00
|
|
|
new1 := new(forgepb.Repo)
|
|
|
|
new1.Name = "bash"
|
|
|
|
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)
|
|
|
|
new1.Name = "zookeeper"
|
|
|
|
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
|
|
|
|
}
|