prick 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -5
  3. data/Gemfile +4 -1
  4. data/TODO +3 -0
  5. data/doc/prick.txt +114 -0
  6. data/exe/prick +224 -370
  7. data/lib/ext/fileutils.rb +11 -0
  8. data/lib/ext/forward_method.rb +18 -0
  9. data/lib/ext/shortest_path.rb +44 -0
  10. data/lib/prick.rb +17 -9
  11. data/lib/prick/branch.rb +254 -0
  12. data/lib/prick/builder.rb +141 -0
  13. data/lib/prick/command.rb +19 -11
  14. data/lib/prick/constants.rb +42 -20
  15. data/lib/prick/database.rb +5 -3
  16. data/lib/prick/diff.rb +47 -0
  17. data/lib/prick/exceptions.rb +15 -3
  18. data/lib/prick/git.rb +46 -21
  19. data/lib/prick/migration.rb +165 -185
  20. data/lib/prick/program.rb +238 -0
  21. data/lib/prick/project.rb +266 -358
  22. data/lib/prick/rdbms.rb +2 -2
  23. data/lib/prick/schema.rb +19 -88
  24. data/lib/prick/share.rb +64 -0
  25. data/lib/prick/state.rb +137 -0
  26. data/lib/prick/version.rb +34 -14
  27. data/libexec/strip-comments +33 -0
  28. data/make_releases +48 -345
  29. data/make_schema +10 -0
  30. data/prick.gemspec +11 -22
  31. data/share/feature_migration/diff.sql +2 -0
  32. data/share/feature_migration/migrate.sql +2 -0
  33. data/share/release_migration/diff.sql +3 -0
  34. data/share/release_migration/features.yml +6 -0
  35. data/share/release_migration/migrate.sql +5 -0
  36. data/share/release_migration/migrate.yml +5 -0
  37. data/share/schema/build.yml +14 -0
  38. data/share/schema/schema.sql +5 -0
  39. data/share/schemas/build.yml +3 -0
  40. data/share/schemas/prick/build.yml +14 -0
  41. data/share/schemas/prick/data.sql +1 -2
  42. data/share/schemas/prick/schema.sql +0 -15
  43. data/share/schemas/prick/tables.sql +17 -0
  44. data/share/schemas/public/.keep +0 -0
  45. data/share/schemas/public/build.yml +14 -0
  46. data/share/schemas/public/schema.sql +3 -0
  47. data/test_assorted +192 -0
  48. data/test_feature +112 -0
  49. data/test_single_dev +83 -0
  50. metadata +34 -61
@@ -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
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/bash
2
+
3
+ SHARE_DIR=share/schemas/schema
4
+ mkdir -p $SHARE_DIR
5
+ NAMES="roles types tables data constraints indexes views functions comments grants"
6
+ for name in $NAMES; do
7
+ name=$name.sql
8
+ file=$SHARE_DIR/$name
9
+ echo -ne "-- ${name}\n\nset search_path to [<SCHEMA>];\n\n" >$file
10
+ done
@@ -1,7 +1,8 @@
1
1
 
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "prick/version"
2
+ #lib = File.expand_path("../lib", __FILE__)
3
+ #$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ #require "prick/version"
5
+ require_relative 'lib/prick/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "prick"
@@ -9,22 +10,14 @@ Gem::Specification.new do |spec|
9
10
  spec.authors = ["Claus Rasmussen"]
10
11
  spec.email = ["claus.l.rasmussen@gmail.com"]
11
12
 
12
- spec.summary = %q{prick gem}
13
- spec.description = %q{prick gem}
13
+ spec.summary = "A release control and management system for postgresql"
14
+ spec.description = "A release control and management system for postgresql"
14
15
  spec.homepage = "http://www.nowhere.com/"
16
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.1")
15
17
 
16
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
18
- # if spec.respond_to?(:metadata)
19
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
- #
21
- # spec.metadata["homepage_uri"] = spec.homepage
22
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
23
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
- # else
25
- # raise "RubyGems 2.0 or newer is required to protect against " \
26
- # "public gem pushes."
27
- # end
18
+ # spec.metadata["homepage_uri"] = spec.homepage
19
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
20
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
28
21
 
29
22
  # Specify which files should be added to the gem when it is released.
30
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -35,11 +28,7 @@ Gem::Specification.new do |spec|
35
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
29
  spec.require_paths = ["lib"]
37
30
 
38
- spec.add_development_dependency "bundler", "~> 2.1"
39
- spec.add_development_dependency "rake", "~> 10.0"
40
- spec.add_development_dependency "rspec", "~> 3.0"
41
-
42
- spec.add_dependency "pg"
31
+ # spec.add_dependency "pg"
43
32
  spec.add_dependency "shellopts", "2.0.0.pre.11"
44
33
  spec.add_dependency "semantic"
45
34
  spec.add_dependency "indented_io"