-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsGenerated.nim
194 lines (153 loc) · 6.77 KB
/
wsGenerated.nim
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import std / [os, strutils, strformat]
import downloadTestRepos
proc buildGraph* =
createDir "buildGraph"
withDir "buildGraph":
createDir "proj_a"
withDir "proj_a":
exec "git init"
writeFile "proj_a.nimble", "requires \"proj_b >= 1.0.0\"\n"
exec "git add proj_a.nimble"
exec "git commit -m 'update'"
exec "git tag v1.0.0"
writeFile "proj_a.nim", "echo \"hello world\"\n"
exec "git add proj_a.nim"
exec "git commit -m 'add nim file'"
writeFile "proj_a.nimble", "requires \"proj_b >= 1.0.0\"\n# comment\n"
exec "git add proj_a.nimble"
exec "git commit -m 'update'"
writeFile "proj_a.nimble", "requires \"proj_b >= 1.1.0\"\n"
exec "git add proj_a.nimble"
exec "git commit -m 'update'"
exec "git tag v1.1.0"
createDir "proj_b"
withDir "proj_b":
exec "git init"
writeFile "proj_b.nim", "echo \"hello world\"\n"
exec "git add proj_b.nim"
exec "git commit -m 'add nim file'"
writeFile "proj_b.nimble", "requires \"proj_c >= 1.0.0\"\n"
exec "git add proj_b.nimble"
exec "git commit -m " & quoteShell("Initial commit for project B")
exec "git tag v1.0.0"
writeFile "proj_b.nimble", "requires \"proj_c >= 1.0.0\"\n# comment\n"
exec "git add proj_b.nimble"
exec "git commit -m " & quoteShell("Update Nimble comment for project B")
writeFile "proj_b.nimble", "requires \"proj_c >= 1.1.0\"\n"
exec "git add proj_b.nimble"
exec "git commit -m " & quoteShell("Update proj_b.nimble for project B")
exec "git tag v1.1.0"
createDir "proj_c"
withDir "proj_c":
exec "git init"
writeFile "proj_c.nimble", "requires \"proj_d >= 1.2.0\"\n"
exec "git add proj_c.nimble"
exec "git commit -m " & quoteShell("Initial commit for project C")
writeFile "proj_c.nimble", "requires \"proj_d >= 1.0.0\"\n"
exec "git commit -am " & quoteShell("Update proj_c.nimble for project C")
exec "git tag v1.2.0"
createDir "proj_d"
withDir "proj_d":
exec "git init"
writeFile "proj_d.nimble", "\n"
exec "git add proj_d.nimble"
exec "git commit -m " & quoteShell("Initial commit for project D")
exec "git tag v1.0.0"
writeFile "proj_d.nimble", "requires \"does_not_exist >= 1.2.0\"\n"
exec "git add proj_d.nimble"
exec "git commit -m " & quoteShell("broken version of package D")
exec "git tag v2.0.0"
proc buildGraphNoGitTags* =
createDir "buildGraphNoGitTags"
withDir "buildGraphNoGitTags":
createDir "proj_a"
withDir "proj_a":
exec "git init"
writeFile "proj_a.nimble", "version = \"1.0.0\"\n\nrequires \"proj_b >= 1.0.0\"\n"
exec "git add proj_a.nimble"
exec "git commit -m 'update'"
writeFile "proj_a.nimble", "version = \"1.0.0\"\n\nrequires \"proj_b >= 1.0.0\"\n# comments\n"
exec "git add proj_a.nimble"
exec "git commit -m 'update nimble comment'"
writeFile "proj_a.nim", "echo \"hello world\"\n"
exec "git add proj_a.nim"
exec "git commit -m 'add nim file'"
writeFile "proj_a.nimble", "version = \"1.1.0\"\n\nrequires \"proj_b >= 1.1.0\"\n"
exec "git add proj_a.nimble"
exec "git commit -m 'update'"
createDir "proj_b"
withDir "proj_b":
exec "git init"
writeFile "proj_b.nim", "echo \"hello world\"\n"
exec "git add proj_b.nim"
exec "git commit -m 'add nim file'"
writeFile "proj_b.nimble", "version = \"1.0.0\"\n\nrequires \"proj_c >= 1.0.0\"\n"
exec "git add proj_b.nimble"
exec "git commit -m " & quoteShell("Initial commit for project B")
writeFile "proj_b.nimble", "version = \"1.0.0\"\n\nrequires \"proj_c >= 1.0.0\"\n# comment\n"
exec "git add proj_b.nimble"
exec "git commit -m " & quoteShell("Update nimble comment")
writeFile "proj_b.nimble", "version = \"1.1.0\"\n\nrequires \"proj_c >= 1.1.0\"\n"
exec "git add proj_b.nimble"
exec "git commit -m " & quoteShell("Update proj_b.nimble for project B")
createDir "proj_c"
withDir "proj_c":
exec "git init"
writeFile "proj_c.nimble", "version = \"1.0.0\"\n\nrequires \"proj_d >= 1.2.0\"\n"
exec "git add proj_c.nimble"
exec "git commit -m " & quoteShell("Initial commit for project C")
writeFile "proj_c.nimble", "version = \"1.2.0\"\n\nrequires \"proj_d >= 1.0.0\"\n"
exec "git commit -am " & quoteShell("Update proj_c.nimble for project C")
createDir "proj_d"
withDir "proj_d":
exec "git init"
writeFile "proj_d.nimble", "version = \"1.0.0\"\n\n"
exec "git add proj_d.nimble"
exec "git commit -m " & quoteShell("Initial commit for project D")
writeFile "proj_d.nimble", "version = \"2.0.0\"\n\nrequires \"does_not_exist >= 1.2.0\"\n"
exec "git add proj_d.nimble"
exec "git commit -m " & quoteShell("broken version of package D")
proc runWsGenerated*() =
withDir("atlas-tests"):
removeDir("working")
createDir "working"
withDir("working"):
buildGraph()
buildGraphNoGitTags()
var repos: seq[tuple[org: string, name: string]]
template findRepo(item) =
if item.kind == pcDir:
# echo "GIT REPO: ", item
let paths = item.path.split(DirSep)
let repo = (org: paths[1], name: paths[2])
# echo "GIT REPO: ", repo
repos.add(repo)
for item in walkDir("working"/"buildGraph"):
findRepo(item)
for item in walkDir("working"/"buildGraphNoGitTags"):
findRepo(item)
echo "Setup bare gits"
removeDir("ws_generated")
createDir("ws_generated")
withDir("ws_generated"):
writeFile("readme.md", "This directory holds the bare git modules used for testing.")
for repo in repos:
createDir(repo.org)
for repo in repos:
echo "REPO: ", repo
withDir(repo.org):
let orig = ".." / ".." / "working" / repo.org / repo.name
echo "CLONING: ", " cwd: ", getCurrentDir()
exec &"git clone --mirror {orig}"
withDir(repo.name & ".git"):
moveFile "hooks"/"post-update.sample", "hooks"/"post-update"
setFilePermissions("hooks"/"post-update", getFilePermissions("hooks"/"post-update") + {fpUserExec})
exec "git update-server-info"
exec &"echo {repo.org}/{repo.name}.git `git rev-parse HEAD` >> ../../ws_generated-manifest.txt"
exec &"echo ============================================== >> ../../ws_generated-logs.txt"
exec &"echo {repo.org}/{repo.name}.git >> ../../ws_generated-logs.txt"
exec &"echo ============================================== '\\n' >> ../../ws_generated-logs.txt"
exec &"git log >> ../../ws_generated-logs.txt"
exec "echo '\\n\\n' >> ../../ws_generated-logs.txt"
when isMainModule:
runWsGenerated()