envirobly 0.5.0 → 0.5.1

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: aefc0201069c2ebcf4e9038a80904d7e3c6b3217a582572db2536cf9f877367e
4
- data.tar.gz: 26b791aa16c6c38613e7ef5b32cc8f1c93eb7342327ed52968e6ee345a9fa12f
3
+ metadata.gz: ca86599ff3741799e0a3faf9d3386c3c937713b15c8fb063dc6c647879eacfd1
4
+ data.tar.gz: d22ece59c009474e6f3bf465e96452eddfc344c344e1a64e4255c88c828d7e12
5
5
  SHA512:
6
- metadata.gz: b5dd97f5d8c19a6e3690884f9f9fc9803a338db2048aaf96a9e5502f68f1d70890a1906f5a478dc998b78e39874cce3db600411a71ee615b41276d63dccdf8c4
7
- data.tar.gz: fe25c4413c314d7368e7fe6b0b05c44f3919159421b75a6511c1ee5c3ba3174ca8c5e3dc52628cd485556a1ef81e92cb2116549573b3d843ed1f753df3ba337b
6
+ metadata.gz: 341a285db112636480ec428f8647ecddc573ce063e64a57e0a79f289bebad4567397c428179d0b109e2e9b443d1e0853f9a4edadbae7280744b42e79381ee834
7
+ data.tar.gz: efed0f09a1fa8a33095d4a838c04a8c2657b7673e986796bc5df68f962e181ad7db975678532a31e2f86f2b2b9efe3ba2fb823b0a7582a91bc5adfc37c2d7253
@@ -36,7 +36,7 @@ class Envirobly::Deployment
36
36
  bucket = response.object.fetch("bucket")
37
37
 
38
38
  puts "Uploading build context, please wait..."
39
- unless commit.archive_and_upload(bucket:, credentials:)
39
+ unless commit.archive_and_upload(bucket:, credentials:).success?
40
40
  $stderr.puts "Error exporting build context. Aborting."
41
41
  exit 1
42
42
  end
@@ -8,47 +8,41 @@ class Envirobly::Git::Commit
8
8
  end
9
9
 
10
10
  def exists?
11
- run(%(cat-file -t #{@ref})).strip == "commit"
11
+ git(%(cat-file -t #{@ref})).stdout.strip == "commit"
12
12
  end
13
13
 
14
14
  def ref
15
- @normalized_ref ||= run(%(rev-parse #{@ref})).strip
15
+ @normalized_ref ||= git(%(rev-parse #{@ref})).stdout.strip
16
16
  end
17
17
 
18
18
  def message
19
- run(%(log #{@ref} -n1 --pretty=%B)).strip
19
+ git(%(log #{@ref} -n1 --pretty=%B)).stdout.strip
20
20
  end
21
21
 
22
22
  def time
23
- Time.parse run(%(log #{@ref} -n1 --date=iso --pretty=format:"%ad"))
23
+ Time.parse git(%(log #{@ref} -n1 --date=iso --pretty=format:"%ad")).stdout
24
24
  end
25
25
 
26
26
  def file_content(path)
27
- run %(show #{@ref}:#{path})
27
+ git(%(show #{@ref}:#{path})).stdout
28
28
  end
29
29
 
30
30
  def objects_with_checksum_at(path)
31
- run(%{ls-tree #{@ref} --format='%(objectname) %(path)' #{path}}).lines.map(&:chomp).
31
+ git(%{ls-tree #{@ref} --format='%(objectname) %(path)' #{path}}).stdout.lines.map(&:chomp).
32
32
  reject { _1.split(" ").last == Envirobly::Config::DIR }
33
33
  end
34
34
 
35
35
  def archive_and_upload(bucket:, credentials:)
36
- `GIT_WORK_TREE="#{@working_dir}" GIT_DIR="#{@working_dir}/.git" git archive --format=tar.gz #{ref} | #{credentials.as_inline_env_vars} aws s3 cp - #{archive_uri(bucket)}`
37
- $?.success?
36
+ git(%(archive --format=tar.gz #{ref} | #{credentials.as_inline_env_vars} aws s3 cp - #{archive_uri(bucket)}))
38
37
  end
39
38
 
40
39
  private
41
- def run(cmd)
42
- @stdout = @stderr = @exit_code = @success = nil
43
- full_cmd = %(GIT_WORK_TREE="#{@working_dir}" GIT_DIR="#{@working_dir}/.git" git #{cmd})
44
- Open3.popen3(full_cmd) do |stdin, stdout, stderr, thread|
40
+ OUTPUT = Struct.new :stdout, :stderr, :exit_code, :success?
41
+ def git(cmd)
42
+ Open3.popen3("git #{cmd}", chdir: @working_dir) do |stdin, stdout, stderr, thread|
45
43
  stdin.close
46
- @stdout = stdout.read
47
- @stderr = stderr.read
48
- @exit_code = thread.value.exitstatus
49
- @success = thread.value.success?
44
+ OUTPUT.new stdout.read, stderr.read, thread.value.exitstatus, thread.value.success?
50
45
  end
51
- @stdout
52
46
  end
53
47
 
54
48
  def archive_uri(bucket)
@@ -1,3 +1,3 @@
1
1
  module Envirobly
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envirobly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Starsi