1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
package main
import (
"os"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
// sent via ldflags
var VERSION string
func main() {
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)
}
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")
os.Exit(0)
}
log.Info("deleted", argv.GoPath, "ok")
f.ConfigSave()
os.Exit(0)
}
// try to update, then save config and exit
if argv.Update {
/*
if f.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 := forgepb.ForgeConfig{
GoPath: argv.GoPath,
Writable: argv.Writable,
ReadOnly: argv.ReadOnly,
Private: argv.Private,
Directory: argv.Directory,
Favorite: argv.Favorite,
Interesting: argv.Interesting,
}
if f.Config.Append(&new1) {
log.Info("added", new1.GoPath, "ok")
} else {
log.Info("added", new1.GoPath, "failed")
os.Exit(-1)
}
f.ConfigSave()
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)")
}
fmt.Println("packages are:", len(all.Repos))
return all
}
*/
|