prick 0.37.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa15e8c866ef97ee0ba04de08ca05ea38b5cf47d6cb156e09be24d3e10a0c8d5
4
- data.tar.gz: 550a8f65c73c1148fa8f9359dbfb7299d0ae2ca4c8acfc3aea7c82f7254c399f
3
+ metadata.gz: 8cc939a1ea84c9e16f586cc4d3ce2a17c63e188996a46cb1b0e8f1b75c25eec8
4
+ data.tar.gz: e379b3a003ceed1b49240a1083f0db8f8cc2fb80d9c4a2800cd82e1005eba03f
5
5
  SHA512:
6
- metadata.gz: 0b6ccea7c28cb6068597899dc8f740629fc7e3d26d7457a06c7c0e76abca1987cf63e422f2be482300c8b44474e0cda941510c1e97653ec4af064c57bb79eea4
7
- data.tar.gz: 2e2685d9b25938dc291204eaa7735a167cbd7014219678dddb86ed6e02aa90c960de3aaf8e79fbe64becfff198d435c5ad05aa1657856ce1e1ea5bacee1de9d2
6
+ metadata.gz: 20c6a454644bf1bc6770eb56cebf20c3bfda8fcde9d70dd2ce0fae7290f47da1b8a5a9254c0b5f04fde8042d38dd0e2f97513fd1b456eff5f49006af36150181
7
+ data.tar.gz: 8b16d64e31172c373d80abd5a5b8303a63888b3a9e5a999e60817a218d3d32ddb12b752bbb1c82057392be39f5ec0cd4811d05464b39f00271fb4deddf06f7a7
data/exe/prick CHANGED
@@ -140,6 +140,10 @@ SPEC = %(
140
140
 
141
141
  The --schema option sets the current schema before executing the PATH
142
142
 
143
+ touch! -- [SUCCESS]
144
+ Record a build. SUCCESS can be 'true' (default) or 'false'. 'touch' is
145
+ used by external build processes that doesn't involve prick
146
+
143
147
  bash! --main
144
148
  Emit a bash script to build the database. The script is constructed from
145
149
  the build attributes in the environment file
@@ -399,6 +403,11 @@ begin
399
403
  database, username, args.expect(1),
400
404
  step: cmd.step?, timer: cmd.time?, dump: dump, schema: cmd.schema)
401
405
 
406
+ when :touch!
407
+ success = args.expect(0..1) || 'true'
408
+ %w(true false).include?(success) or ShellOpts.error "Illegal argument '#{success}'"
409
+ Prick::SubCommand.touch(success == "true")
410
+
402
411
  when :bash!
403
412
  args.expect(0)
404
413
  clean_pg_meta_cache
@@ -413,6 +422,11 @@ begin
413
422
  args.expect(0)
414
423
  Prick::SubCommand.snapshot(database, username)
415
424
 
425
+ when :reset!
426
+ require_db
427
+ args.expect(0)
428
+ Prick::SubCommand.drop_data(database)
429
+
416
430
  when :drop!
417
431
  case cmd.subcommand
418
432
  when :users!
@@ -97,8 +97,8 @@ module Command
97
97
  # will instead return a tuple of stdout/stderr lines. If :stderr is false,
98
98
  # stderr is ignored and is the same as adding "2>/dev/null" to the command
99
99
  #
100
- # #command raises a Command::Error exception if the command returns with an exit
101
- # code != 0 unless :fail is false. In that case the the exit code can be
100
+ # #command raises a Command::Error exception if the command returns with an
101
+ # exit code != 0 unless :fail is false. In that case the the exit code can be
102
102
  # fetched from Command::status
103
103
  #
104
104
  def command(env = {}, cmd, stdin: nil, stderr: nil, fail: true)
@@ -62,6 +62,8 @@ module Prick
62
62
  # Access to branch methods
63
63
  def self.branch() Branch end
64
64
 
65
+ # List files in repository
66
+ def self.list() Command.command("git ls-files") end
65
67
 
66
68
  module Tag
67
69
  # The associated commit ID of a tag
data/lib/prick/state.rb CHANGED
@@ -239,7 +239,7 @@ module Prick
239
239
  # It is an error if the project file exists.
240
240
  def save_project(overwrite: false)
241
241
  overwrite || !File.exists?(project_file) or Prick.error "Won't overwrite '#{project_file}'"
242
- hash = { name: name, title: title, version: version.to_s, prick: prick_version.to_s }
242
+ hash = { name: name, title: title, version: version.to_s, prick: Prick::VERSION }
243
243
  save_yaml(project_file, hash)
244
244
  end
245
245
 
@@ -264,10 +264,11 @@ module Prick
264
264
  @build_id = insert_record(
265
265
  "prick.builds",
266
266
  name: name,
267
- version: version.to_s, prick: prick_version,
267
+ version: version.to_s, prick: Prick::VERSION,
268
268
  branch: branch, rev: rev(kind: :short), clean: clean?,
269
269
  environment: environment)
270
270
  end
271
+ # version: version.to_s, prick: prick_version,
271
272
  end
272
273
 
273
274
  def save_build_end(success, duration)
@@ -278,13 +279,23 @@ module Prick
278
279
  insert_record(
279
280
  "prick.builds",
280
281
  name: name,
281
- version: version.to_s, prick: prick_version,
282
+ version: version.to_s, prick: Prick::VERSION,
282
283
  branch: branch, rev: rev(kind: :short), clean: clean?,
283
284
  environment: environment,
284
285
  success: success, duration: duration, prick_duration: dt)
285
286
  end
286
287
  end
287
288
 
289
+ def save_build(success = true)
290
+ insert_record(
291
+ "prick.builds",
292
+ name: name,
293
+ version: version.to_s, prick: Prick::VERSION,
294
+ branch: branch, rev: rev(kind: :short), clean: clean?,
295
+ environment: environment,
296
+ success: success)
297
+ end
298
+
288
299
  def dump
289
300
  puts "State"
290
301
  indent {
@@ -42,7 +42,10 @@ module Prick::SubCommand
42
42
  if format == :short
43
43
  puts Prick.databases
44
44
  else
45
- fs_time = `find . -type f -not -path '*/\.*' -printf '%TF %TT\n' | sort -r | head -n 1`
45
+ # Timestamp of newest file under git control
46
+ newest_file = Command.command("ls -tr #{Git.list.join(" ")} | tail -1").last
47
+ fs_time = File.mtime(newest_file)
48
+
46
49
  git_branch = Git.branch.current
47
50
  git_rev = Git.id[0...8]
48
51
 
@@ -51,10 +54,7 @@ module Prick::SubCommand
51
54
  row = conn.record(%(
52
55
  select
53
56
  '#{database}' as "database", name, version, branch, rev, clean, environment,
54
- to_char(
55
- built_at at time zone 'UTC' at time zone current_setting('TimeZone'),
56
- 'YYYY-MM-DD HH24:MI') as "built_at",
57
- success
57
+ built_at, success
58
58
  from prick.versions
59
59
  ))
60
60
 
@@ -62,6 +62,8 @@ module Prick::SubCommand
62
62
  clean = row[:clean]
63
63
  same_revision = row[:branch] == git_branch && row[:rev] == git_rev
64
64
  up2date = fs_time <= row[:built_at]
65
+
66
+ # Set state
65
67
  row[:state] =
66
68
  case [clean, same_revision, up2date]
67
69
  in [true, true, true]; "clean" # Clean repo
@@ -76,6 +78,10 @@ module Prick::SubCommand
76
78
  row[:state] = "-"
77
79
  end
78
80
 
81
+ # Convert built_at to string
82
+ row[:built_at] = row[:built_at].strftime("%Y-%m-%d %H:%M")
83
+
84
+ # Add current database marker
79
85
  last_column = (Prick.state.database == database ? "*" : "")
80
86
  rows << row.values + [last_column]
81
87
  }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../builder/builder.rb'
4
+
5
+ module Prick::SubCommand
6
+ def self.touch(success)
7
+ Prick.state.save_build(success)
8
+ end
9
+ end
data/lib/prick/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prick
4
- VERSION = "0.37.0"
4
+ VERSION = "0.39.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.37.0
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-10 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic
@@ -235,6 +235,7 @@ files:
235
235
  - lib/prick/subcommand/prick-setup.rb
236
236
  - lib/prick/subcommand/prick-snapshot.rb
237
237
  - lib/prick/subcommand/prick-teardown.rb
238
+ - lib/prick/subcommand/prick-touch.rb
238
239
  - lib/prick/subcommand/subcommand.rb
239
240
  - lib/prick/version.rb
240
241
  - prick.gemspec