prick 0.38.0 → 0.39.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e44c6bb60e5ae3fe9a90935d641c116ccac1ff93790385880085dbe65cbca19c
4
- data.tar.gz: bc04dc4f8f7c145c36f46fdeacb7ebb0fd751c4446f4adf1ecc0f2449098b6a5
3
+ metadata.gz: 8cc939a1ea84c9e16f586cc4d3ce2a17c63e188996a46cb1b0e8f1b75c25eec8
4
+ data.tar.gz: e379b3a003ceed1b49240a1083f0db8f8cc2fb80d9c4a2800cd82e1005eba03f
5
5
  SHA512:
6
- metadata.gz: 3a210f76e1d1ad412185a9bc52229ecb48119e3e5542d216e26750116cd6e807bce7d6435a293987dfa897ba5ded23c39f26a287259d8ebc55ec5154610a720c
7
- data.tar.gz: e59379e97b66b72be5a6d43288ce8665f6dd3400f99e5ed5ec39308b2fe849592b143819f36e6c3f5ce6ca2edb9e1db5775e697cf171ead49832a71ab4877954
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
@@ -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
@@ -286,6 +286,16 @@ module Prick
286
286
  end
287
287
  end
288
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
+
289
299
  def dump
290
300
  puts "State"
291
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.38.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.38.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-15 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