prick 0.2.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -5
  3. data/Gemfile +4 -1
  4. data/TODO +10 -0
  5. data/doc/prick.txt +114 -0
  6. data/exe/prick +328 -402
  7. data/lib/ext/fileutils.rb +18 -0
  8. data/lib/ext/forward_method.rb +18 -0
  9. data/lib/ext/shortest_path.rb +44 -0
  10. data/lib/prick.rb +20 -10
  11. data/lib/prick/branch.rb +254 -0
  12. data/lib/prick/builder.rb +164 -0
  13. data/lib/prick/cache.rb +34 -0
  14. data/lib/prick/command.rb +19 -11
  15. data/lib/prick/constants.rb +122 -48
  16. data/lib/prick/database.rb +28 -20
  17. data/lib/prick/diff.rb +125 -0
  18. data/lib/prick/exceptions.rb +15 -3
  19. data/lib/prick/git.rb +77 -30
  20. data/lib/prick/head.rb +183 -0
  21. data/lib/prick/migration.rb +40 -200
  22. data/lib/prick/program.rb +493 -0
  23. data/lib/prick/project.rb +523 -351
  24. data/lib/prick/rdbms.rb +4 -13
  25. data/lib/prick/schema.rb +16 -90
  26. data/lib/prick/share.rb +64 -0
  27. data/lib/prick/state.rb +192 -0
  28. data/lib/prick/version.rb +62 -29
  29. data/libexec/strip-comments +33 -0
  30. data/make_releases +48 -345
  31. data/make_schema +10 -0
  32. data/prick.gemspec +14 -23
  33. data/share/diff/diff.after-tables.sql +4 -0
  34. data/share/diff/diff.before-tables.sql +4 -0
  35. data/share/diff/diff.tables.sql +8 -0
  36. data/share/migration/diff.tables.sql +8 -0
  37. data/share/migration/features.yml +6 -0
  38. data/share/migration/migrate.sql +3 -0
  39. data/share/migration/migrate.yml +8 -0
  40. data/share/migration/tables.sql +3 -0
  41. data/share/schema/build.yml +14 -0
  42. data/share/schema/schema.sql +5 -0
  43. data/share/schema/schema/build.yml +3 -0
  44. data/share/schema/schema/prick/build.yml +14 -0
  45. data/share/schema/schema/prick/data.sql +7 -0
  46. data/share/schema/schema/prick/schema.sql +5 -0
  47. data/share/{schemas/prick/schema.sql → schema/schema/prick/tables.sql} +2 -5
  48. data/{file → share/schema/schema/public/.keep} +0 -0
  49. data/share/schema/schema/public/build.yml +14 -0
  50. data/share/schema/schema/public/schema.sql +3 -0
  51. data/test_assorted +192 -0
  52. data/test_feature +112 -0
  53. data/test_refactor +34 -0
  54. data/test_single_dev +83 -0
  55. metadata +43 -68
  56. data/lib/prick/build.rb +0 -376
  57. data/lib/prick/migra.rb +0 -22
  58. data/share/schemas/prick/data.sql +0 -8
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/bash
2
+
3
+ # NAME
4
+ # strip-comments - Remove comments from postgres files
5
+ #
6
+ # USAGE
7
+ # strip-comments [FILE]
8
+ #
9
+ # DESCRIPTION
10
+ # Remove comments and blank lines from standard intput or the given file and
11
+ # write the result on standard output
12
+ #
13
+ # REFERENCES
14
+ # https://stackoverflow.com/a/35708616/1745001
15
+ #
16
+
17
+ PROGRAM=$(basename $0)
18
+ USAGE="[FILE]"
19
+
20
+ function error() {
21
+ echo "$PROGRAM: $@"
22
+ echo "Usage: $PROGRAM $USAGE"
23
+ exit 1
24
+ } >&2
25
+
26
+ [ $# -le 1 ] || error "Illegal number of arguments"
27
+ FILE=$1
28
+
29
+ sed '/^\s*--/d' $FILE \
30
+ | sed 's/a/aA/g; s/__/aB/g; s/#/aC/g' \
31
+ | gcc -P -E -ansi - \
32
+ | sed 's/aC/#/g; s/aB/__/g; s/aA/a/g'
33
+
data/make_releases CHANGED
@@ -1,369 +1,72 @@
1
1
  #!/usr/bin/bash
2
2
 
3
3
  set -e
4
- set -u
5
- set -o pipefail
6
4
 
7
- use_cache=false
8
- create_cache=true
9
-
10
-
11
-
12
- clear
13
-
14
- ORG=$PWD
15
- DIR=prj
16
- PROJECT=prj
17
- BASE=$PWD/$DIR
18
-
19
- PUBLIC=schemas/public/schema.sql
20
-
21
- alias prick='\prick -n $PROJECT'
22
-
23
- rm -rf $DIR
24
-
25
- echo "*** Initializing project"
26
- prick -n $PROJECT init $DIR
27
- cd $DIR
28
- prick status
29
- echo
30
-
31
- echo "*** Create feature_a"
32
- prick checkout 0.0.0
33
- prick create feature feature_a
34
- echo
35
-
36
- echo "*** Add table public.a"
37
- echo "create table a (id integer);" >>$PUBLIC
38
- git add $PUBLIC
39
- git commit -m "Added public.a (feature_a)"
40
- echo
41
-
42
- echo "*** Create migration"
43
- prick prepare migration
44
- echo "\\i diff.sql" >>features/0.0.0/feature_a/migrate.sql
45
- git commit -am "Prepared migration"
46
- echo
47
-
48
- echo "*** Create feature_b"
49
- prick checkout 0.0.0
50
- prick create feature feature_b
51
- echo "create table b (id integer);" >>$PUBLIC
52
- git add $PUBLIC
53
- git commit -m "Added public.b (feature_b)"
54
- echo
55
-
56
- echo "*** Create migration"
57
- prick prepare migration
58
- echo "\\i diff.sql" >>features/0.0.0/feature_b/migrate.sql
59
- git commit -am "Prepared migration"
60
- echo
61
-
62
- echo "*** Create 0.1.0-pre.0"
63
- prick checkout 0.0.0
64
- prick create prerelease minor
65
- prick status
66
- echo
67
-
68
- echo "*** Include feature_a"
69
- prick include 0.0.0_feature_a
70
- prick commit
71
- echo
72
-
73
- echo "*** Create release 0.1.0"
74
- prick release
75
- prick status
76
- echo
77
-
78
- echo "*** Create 0.1.1-pre.0"
79
- prick checkout 0.1.0
80
- prick create prerelease patch
81
- echo
82
-
83
- echo "*** Include feature_b"
84
- prick include 0.0.0_feature_b
85
- sed -i -e '/<<<</d' -e '/====/d' -e '/>>>>/d' $PUBLIC
86
- git add $PUBLIC
87
- prick commit
88
- echo
89
-
90
- echo "*** Release 0.2.0"
91
- prick release
92
- prick status
93
- echo
94
-
95
-
96
-
97
-
98
-
99
- #echo "*** Prepare migration"
100
- #prick prepare migration
101
- #echo
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
- exit
112
-
113
- ###################################
114
-
115
- echo "*** Initializing project"
116
- prick -n $PROJECT init $DIR
117
- cd $DIR
118
- prick status
119
- echo
120
-
121
- echo "*** Create feature_a"
122
- prick checkout 0.0.0
123
- prick create feature feature_a
124
- echo
125
-
126
- echo "*** Create feature_b"
127
- prick checkout 0.0.0
128
- prick create feature feature_b
129
- echo
130
-
131
- echo "*** Create feature_c"
132
- prick checkout 0.0.0
133
- prick create feature feature_c
134
- echo
135
-
136
- echo "*** Create feature_d"
137
- prick checkout 0.0.0
138
- prick create feature feature_d
139
- echo
140
-
141
- echo "*** Checkout 0.0.0"
142
- prick checkout 0.0.0
143
- prick status
144
- echo
145
-
146
- echo "*** Create 0.1.0-pre.0"
147
- prick checkout 0.0.0
148
- prick create prerelease minor
149
- prick status
150
- echo
151
-
152
- echo "*** Include feature_a"
153
- prick include "0.0.0_feature_a"
154
- prick commit
155
- echo
156
-
157
- echo "*** Release 0.1.0"
158
- prick release
159
- prick status
160
- echo
161
-
162
- echo "*** Checkout 0.0.0_feature_c"
163
- prick checkout 0.0.0_feature_c
164
- prick status
165
- echo
166
-
167
- echo "*** Include feature_b in feature_c"
168
- prick include 0.0.0_feature_b
169
- prick commit
170
- echo
171
-
172
- echo "*** Create 0.2.0-pre.0"
173
- prick checkout 0.1.0
174
- prick create prerelease minor
175
- prick status
176
-
177
- echo "*** Include feature_c"
178
- prick include 0.0.0_feature_c
179
- prick commit
5
+ rm -rf dir
6
+ echo "Initialize prick"
180
7
  echo
8
+ prick --name prj init dir
9
+ (
10
+ cd dir
181
11
 
182
- echo "*** Release 0.2.0"
183
- prick release
184
- prick status
185
- echo
186
-
187
- echo "*** Create 1.0.0-pre.0"
188
- prick checkout 0.2.0
189
- prick create prerelease major
190
- prick status
191
-
192
- echo "create table tt (id integer)" >schemas/public/schema.sql
193
- git add schemas/public/schema.sql
194
- git commit -m "Added table public.tt"
195
-
196
- prick prepare migration
197
-
198
-
199
- #echo "*** Checkout 0.0.0_feature_d"
200
- #prick checkout 0.0.0_feature_d
201
- #prick status
202
- #echo
203
- #
204
- #echo "*** Rebase to 0.2.0"
205
- #prick rebase 0.2.0
206
-
207
-
208
- exit
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
12
+ echo "Prepare an unnamed release"
13
+ prick prepare
14
+ echo
223
15
 
16
+ echo "Create release 0.0.1"
17
+ prick create release 0.0.1
18
+ echo
224
19
 
225
-
226
-
227
-
228
- if ! $use_cache; then
229
- prick -n $PROJECT init $DIR
230
- cd $DIR
231
-
20
+ echo "Create feature_a"
232
21
  prick create feature feature_a
233
- echo "create table feature_a_table (id integer);" >schemas/public/schema.sql
234
- git add schemas/public/schema.sql
235
- git commit -m "Added public.feature_a_table"
236
- prick checkout 0.0.0
237
- prick create prerelease minor
238
- prick include 0.0.0_feature_a
239
- prick commit
240
- prick create release
22
+ echo
241
23
 
242
- prick create feature feature_b
243
- echo "create table feature_b_table (id integer);" >>schemas/public/schema.sql
24
+ echo "Update schema"
25
+ echo "create table t (id integer)" >> schemas/public/schema.sql
244
26
  git add schemas/public/schema.sql
245
- git commit -m "Added public.feature_b_table"
246
- prick checkout 0.1.0
247
- prick create feature feature_b2
248
- prick include 0.1.0_feature_b
249
- prick commit
250
- prick checkout 0.1.0
251
- prick create prerelease minor
252
- # prick include 0.1.0_feature_b
253
- # prick commit
254
- prick create release
255
-
256
- if $create_cache; then
257
- cd $ORG
258
- tar -zcf $DIR.tar.gz $DIR
259
- cd $DIR
260
- fi
261
- else
262
- tar -zxf $DIR.tar.gz $DIR
263
- cd $DIR
264
- fi
265
-
266
- prick checkout 0.2.0
267
- git status
268
- prick create feature feature_c
269
- git status
270
-
271
- prick checkout 0.2.0
272
- prick create feature feature_d
273
- prick checkout 0.2.0_feature_d
274
- prick include 0.2.0_feature_c
275
- prick commit
276
-
277
- prick checkout 0.2.0
278
- prick create prerelease minor
279
- prick include 0.2.0_feature_c
280
- prick commit
281
- prick include 0.2.0_feature_d
282
- prick commit
283
- prick include 0.1.0_feature_b2
284
- prick commit
285
-
286
- prick create release
287
-
288
- # TODO features of older releases symlinks
289
-
27
+ git commit -m "Added PUBLIC.T"
290
28
 
291
- mkdir migrations/0.0.0_0.2.0
292
- cd migrations/0.0.0_0.2.0
293
- touch migrations.sql
294
- touch features.sql
295
- touch diff.sql
296
- ln -s ../../features/0.1.0/feature_b .
297
- cd -
29
+ echo "Build branch"
30
+ prick build
31
+ psql -d prj -c "select version from prick.versions"
298
32
 
299
- #mkdir features/0.3.0
33
+ exit
300
34
 
301
-
302
-
303
- exit
304
-
305
-
306
- {
307
- dropdb prick-0.1.0 || true
308
- dropdb prick-0.2.0 || true
309
- } &>/dev/null
310
-
311
- prick -n $PROJECT build 0.1.0
312
- prick -n $PROJECT build 0.2.0
313
-
314
-
315
- exit
316
-
317
- if ! $use_cache; then
318
- prick -n $PROJECT init $DIR
319
- cd $DIR
320
-
321
- prick create prerelease minor
322
- prick create release # 0.1.0
323
- prick create feature my_feature # 0.1.0_my_feature
324
- prick checkout 0.1.0
325
- prick create feature another_feature
326
- prick checkout 0.1.0
35
+ echo "Create prerelease 0.1.0.pre.1"
327
36
  prick create prerelease minor
37
+ echo
328
38
 
329
- if $create_cache; then
330
- cd $ORG
331
- tar -zcf $DIR.tar.gz $DIR
332
- cd $DIR
333
- fi
334
- else
335
- tar -zxf $DIR.tar.gz $DIR
336
- cd $DIR
337
- fi
39
+ echo "Increment prerelease"
40
+ prick create prerelease
41
+ echo
338
42
 
339
- prick include 0.1.0_my_feature
340
- prick commit
43
+ echo "Release (0.1.0)"
44
+ prick create release
45
+ echo
341
46
 
47
+ echo "Create release 0.2.0"
48
+ prick create release 0.2.0
49
+ echo
342
50
 
343
- exit
51
+ echo "Prepare migration"
52
+ prick prepare migration 0.0.0
53
+ echo
344
54
 
345
- if ! $use_cache; then
346
- prick -n $PROJECT init $DIR
347
- cd $DIR
55
+ echo "Create migration"
56
+ prick create migration
57
+ echo
348
58
 
349
- prick create prerelease minor
350
- prick increment prerelease
351
- prick create release
352
-
353
- prick prerelease minor
354
- prick release
59
+ # echo "Create release 0.3.0"
60
+ # git checkout 0.2.0
61
+ # prick create release 0.3.0
62
+ # echo
63
+ #
64
+ # echo "Retarget 0.0.0 -> 0.3.0"
65
+ # git checkout 0.0.0_0.2.0
66
+ # prick retarget 0.3.0
67
+ # echo
355
68
 
356
- if $create_cache; then
357
- cd $ORG
358
- tar -zcf $DIR.tar.gz $DIR
359
- cd $DIR
360
- fi
361
- else
362
- tar -zxf $DIR.tar.gz $DIR
363
- cd $DIR
364
- fi
69
+ tree -a -I .git
70
+ )
365
71
 
366
- prick prepare
367
- prick release 0.2.1
368
72
 
369
- #clear; rm -rf ex; prick -n prick init ex && tree ex && (cd ex; git log; git status); prick -C ex -n prick prepare minor; prick -C ex -n prick prerelease