heroku_tool 0.9.2 → 0.9.3

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: 4b5e399a4542b07992fbc0e896bf8b1f6fca73cb3abf66647c0c741e013ee910
4
- data.tar.gz: b06141618a185a433edbb74786d6ea572a0079220bf22f4f6724b87a86e8ac30
3
+ metadata.gz: 5aff0c40aebac826f0c564531114ce61762c7e1fed7ad87b281160c7b27bccd0
4
+ data.tar.gz: b8ff4953f2f385b49f7a25a8f276bdce0e5221f34db9a5207b3f60fb3ebe1c63
5
5
  SHA512:
6
- metadata.gz: 54d7a075669af48e1a62a59cf077ce577114e565487b1997f0bad47edb2f26c74250a82ea9b501f058ef66ec4ec4157086ba3c96aaed66f163b24c70aa2b7096
7
- data.tar.gz: ea5187d7722b88eb0cf01065ae624f65effa27457257a3e6081b22294dbc3e893a0d3d74c0cff36cbd7a38c01c51a1b68db057688c9a1fc27789fab6c8dde047
6
+ metadata.gz: 7275494d3fbd74ac696cd30394b8a7969594c6c77e2ad9aac787a1562247956a3b28de99940a6f085da2b55d99337a3a207c66b441710c0f50c2328d92055783
7
+ data.tar.gz: 8a49007bd74cd1b5cedf559e3d7ad0afaae2765eef98d9c25b2003e04afedb7c422052f168d2fc6e3fb4ec090beb28583fc05719c785703230a18764b9d2f9fe
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.9.3
4
+
5
+ record the app revision using git describe, at the beginning of the process (in case of accidental branch switches)
6
+
7
+ ## v0.9.2
8
+
9
+ update and fix bugsnag deploy tracking
10
+
3
11
  ## v0.9.1
4
12
 
5
13
  support url in heroku targets
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "open3"
4
+ require "shellwords"
4
5
 
5
6
  module HerokuTool
6
7
  class Commander
@@ -14,13 +15,21 @@ module HerokuTool
14
15
  @configuration = configuration
15
16
  end
16
17
 
18
+ # The deploy ref is resolved to a commit once, before anything else happens, and that commit is what gets
19
+ # described, pushed and recorded: checking out another branch (or fetching) while the deploy is running
20
+ # doesn't change what is deployed or how it is reported.
21
+ #
22
+ # @return [String, false] the revision (commit sha) that was deployed, or false if the deploy failed
17
23
  def deploy(deploy_ref, with_maintenance:)
18
- deploy_ref_description = deploy_ref_describe(deploy_ref)
24
+ revision = resolve_revision(deploy_ref)
25
+ return false unless revision
26
+
27
+ deploy_ref_description = deploy_ref_describe(revision)
19
28
  puts "Deploy #{deploy_ref_description} to #{target} with migrate=#{target.migrate_in_release_phase ? "(during release phase)" : migrate_outside_of_release_phase?} with_maintenance=#{with_maintenance} "
20
29
 
21
- output_to_be_deployed(deploy_ref)
30
+ output_to_be_deployed(revision)
22
31
  configuration.before_deploying(self, target, deploy_ref_description)
23
- successful_push = puts_and_system "git push -f #{target.git_remote} #{deploy_ref || target}^{}:#{target.heroku_target_ref}"
32
+ successful_push = puts_and_system "git push -f #{target.git_remote} #{revision}:#{target.heroku_target_ref}"
24
33
 
25
34
  return false unless successful_push
26
35
 
@@ -32,12 +41,22 @@ module HerokuTool
32
41
  app_revision_env_var = configuration.app_revision_env_var
33
42
  if app_revision_env_var && app_revision_env_var != "HEROKU_SLUG_COMMIT"
34
43
  # HEROKU_SLUG_COMMIT is automatically set by https://devcenter.heroku.com/articles/dyno-metadata
35
- puts_and_system %{heroku config:set #{app_revision_env_var}=$(git describe --always #{deploy_ref}) -a #{target.heroku_app}}
44
+ puts_and_system "heroku config:set #{app_revision_env_var}=#{Shellwords.escape(deploy_ref_description)} -a #{target.heroku_app}"
36
45
  end
37
46
 
38
47
  maintenance_off if with_maintenance
39
48
  configuration.after_deploying(self, target, deploy_ref_description)
40
- true
49
+ revision
50
+ end
51
+
52
+ # @return [String, nil] the sha of the commit that deploy_ref (or the target's deploy_ref) points at right now
53
+ def resolve_revision(deploy_ref = nil)
54
+ deploy_ref ||= target.deploy_ref
55
+ revision = `git rev-parse --verify --quiet #{deploy_ref}^{commit}`.strip
56
+ return revision unless revision.empty?
57
+
58
+ puts "❌ Can't resolve '#{deploy_ref}' to a commit"
59
+ nil
41
60
  end
42
61
 
43
62
  def maintenance_on
@@ -55,7 +74,7 @@ module HerokuTool
55
74
  end
56
75
 
57
76
  def deploy_ref_describe(deploy_ref = nil)
58
- `git describe #{deploy_ref || target.deploy_ref}`.strip
77
+ `git describe --always #{deploy_ref || target.deploy_ref}`.strip
59
78
  end
60
79
 
61
80
  def output_to_be_deployed(since_deploy_ref = nil)
@@ -135,9 +135,9 @@ class Heroku < Thor
135
135
  check_deploy_ref(deploy_ref)
136
136
  with_maintenance = options[:maintenance].nil? && migrate_outside_of_release_phase? || options[:maintenance] || false
137
137
  deploy_ref ||= target.deploy_ref
138
- success = commander.deploy(deploy_ref, with_maintenance: with_maintenance)
139
- if success
140
- deploy_tracking(target_name, deploy_ref)
138
+ deployed_revision = commander.deploy(deploy_ref, with_maintenance: with_maintenance)
139
+ if deployed_revision
140
+ deploy_tracking(target_name, deployed_revision)
141
141
  else
142
142
  exit(-1)
143
143
  end
@@ -1,3 +1,3 @@
1
1
  module HerokuTool
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Diggins
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0'
175
175
  requirements: []
176
- rubygems_version: 4.0.11
176
+ rubygems_version: 3.6.9
177
177
  specification_version: 4
178
178
  summary: Tool for configurable one-shot deployment and db managment with heroku and
179
179
  rails