heroku_hatchet 1.1.9 → 1.2.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
  SHA1:
3
- metadata.gz: 3cac48b3f78e361924cf97f575634fed07bb6474
4
- data.tar.gz: 177886238aa528b57365d9cf8b47bc4f3d4f96f2
3
+ metadata.gz: 41fe3c7326911d5c112ba7ef95ef7f25397fb59e
4
+ data.tar.gz: eba86db8f7652204a308b910e5d2e01c160b15f4
5
5
  SHA512:
6
- metadata.gz: d77a4f52a1506d979f31c5518114a14e43efeb2b773834dabf1a4941f06e68555d0357df1f760b43c3ffacc0138e53c09952c27a565dee340d1c4254376ed3ce
7
- data.tar.gz: 8bbbb34ad178c195e4a0106e865b0ebd842ca0e8c254270cffb75fee3befb18f86de9c3a53a78d7bd7d72450e3455dfe480ce1aee0be6e164ab88588b337c6e7
6
+ metadata.gz: 82f41b5be9b220f58b504829044a7da3e38f690af0862a59692ac28cf61e0fc70808a99d6fb7878aaa69007108771dc55362349fdffeec2f1333bf8dbfefa7a2
7
+ data.tar.gz: 0f4a2b231c42870ffebbe886c0eaab1f4dd158a824321b7209846302a3a75389a71ed397d16cd7e3e1aa3d58fb46a9059fe2ebcbd5d3b50645d3b067b991b6cf
data/.gitignore CHANGED
@@ -4,4 +4,5 @@ test/fixtures/repos/*
4
4
 
5
5
 
6
6
  Gemfile.lock
7
- debug.rb
7
+ debug.rb
8
+ .ruby-version
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## HEAD
2
2
 
3
+ ## 1.2.0
4
+
5
+ - Change `App#push` default behavior to be `App#push_with_retry!`
6
+ - `App#in_directory` now copies source repo to tmpdir so it can be modified if needed
7
+ - Repo name now shows up in error outputs.
8
+
3
9
  ## 1.1.9
4
10
 
5
11
  - Use TRAVIS_BRANCH if present
@@ -10,7 +10,7 @@ module Hatchet
10
10
  super
11
11
  end
12
12
 
13
- def push!
13
+ def push_without_retry!
14
14
  out, err = wrap_stdout_and_rescue(Anvil::Builder::BuildError) do
15
15
  slug_url = Anvil::Engine.build(".", :buildpack => @buildpack, :pipeline => true)
16
16
  puts "Releasing to http://#{@name}.herokuapp.com"
data/lib/hatchet/app.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  module Hatchet
2
2
  class App
3
- attr_reader :name, :directory
3
+ attr_reader :name, :directory, :repo_name
4
4
 
5
5
  class FailedDeploy < StandardError
6
6
  def initialize(app, output)
7
- msg = "Could not deploy '#{app.name}' using '#{app.class}' at path: '#{app.directory}'\n" <<
7
+ msg = "Could not deploy '#{app.name}' (#{app.repo_name}) using '#{app.class}' at path: '#{app.directory}'\n" <<
8
8
  " if this was expected add `allow_failure: true` to your deploy hash.\n" <<
9
9
  "output:\n" <<
10
10
  "#{output}"
@@ -13,7 +13,8 @@ module Hatchet
13
13
  end
14
14
 
15
15
  def initialize(repo_name, options = {})
16
- @directory = config.path_for_name(repo_name)
16
+ @repo_name = repo_name
17
+ @directory = config.path_for_name(@repo_name)
17
18
  @name = options[:name] || "test-app-#{Time.now.to_f}".gsub('.', '-')
18
19
  @debug = options[:debug] || options[:debugging]
19
20
  @allow_failure = options[:allow_failure] || false
@@ -102,7 +103,7 @@ module Hatchet
102
103
  self
103
104
  end
104
105
 
105
- def push!
106
+ def push_without_retry!
106
107
  raise NotImplementedError
107
108
  end
108
109
 
@@ -116,8 +117,11 @@ module Hatchet
116
117
  end
117
118
 
118
119
  def in_directory(directory = self.directory)
119
- Dir.chdir(directory) do
120
- yield directory
120
+ Dir.mktmpdir do |tmpdir|
121
+ FileUtils.cp_r("#{directory}/.", "#{tmpdir}/.")
122
+ Dir.chdir(tmpdir) do
123
+ yield directory
124
+ end
121
125
  end
122
126
  end
123
127
 
@@ -136,21 +140,26 @@ module Hatchet
136
140
  end
137
141
 
138
142
 
139
- def push_with_retry!
140
- RETRIES.times.retry do |attempt|
143
+ def push
144
+ max_retries = @allow_failure ? 1 : RETRIES
145
+ max_retries.times.retry do |attempt|
141
146
  begin
142
- @output = self.push!
147
+ @output = self.push_without_retry!
143
148
  rescue StandardError => error
144
- puts retry_error_message(error, attempt)
149
+ puts retry_error_message(error, attempt, max_retries)
145
150
  raise error
146
151
  end
147
152
  end
148
153
  end
154
+ alias :push! :push
155
+ alias :push_with_retry :push
156
+ alias :push_with_retry! :push_with_retry
157
+
149
158
 
150
- def retry_error_message(error, attempt)
159
+ def retry_error_message(error, attempt, max_retries)
151
160
  attempt += 1
152
- return "" if attempt == RETRIES
153
- msg = "\nRetrying failed Attempt ##{attempt}/#{RETRIES} to push for '#{name}' due to error: \n"<<
161
+ return "" if attempt == max_retries
162
+ msg = "\nRetrying failed Attempt ##{attempt}/#{max_retries} to push for '#{name}' due to error: \n"<<
154
163
  "#{error.class} #{error.message}\n #{error.backtrace.join("\n ")}"
155
164
  end
156
165
 
@@ -19,7 +19,9 @@ module Hatchet
19
19
  "git@heroku.com:#{name}.git"
20
20
  end
21
21
 
22
- def push!
22
+ def push_without_retry!
23
+ puts `pwd`
24
+ puts `ls`
23
25
  output = `git push #{git_repo} master 2>&1`
24
26
  if !$?.success?
25
27
  raise FailedDeploy.new(self, "Buildpack: #{@buildpack.inspect}\nRepo: #{git_repo}\n#{output}") unless @allow_failure
@@ -1,3 +1,3 @@
1
1
  module Hatchet
2
- VERSION = "1.1.9"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -20,13 +20,14 @@ class AllowFailureAnvilTest < Test::Unit::TestCase
20
20
  end
21
21
 
22
22
  def test_retries
23
+ orig_retries = Hatchet::RETRIES
23
24
  Hatchet.const_set(:RETRIES, 2)
24
25
  assert_raise(Anvil::Builder::BuildError) do
25
26
  app = Hatchet::AnvilApp.new("no_lockfile", buildpack: @buildpack_path)
26
- app.expects(:push!).twice.raises(Anvil::Builder::BuildError)
27
+ app.expects(:push_without_retry!).twice.raises(Anvil::Builder::BuildError)
27
28
  app.deploy
28
29
  end
29
30
  ensure
30
- Hatchet.const_set(:RETRIES, 1)
31
+ Hatchet.const_set(:RETRIES, orig_retries)
31
32
  end
32
33
  end
@@ -30,7 +30,6 @@ class MultiCmdRunnerTest < Test::Unit::TestCase
30
30
  bash.run("ls") { |r| assert_match "Gemfile", r }
31
31
  end
32
32
  end
33
-
34
33
  end
35
34
  end
36
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_hatchet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-28 00:00:00.000000000 Z
11
+ date: 2014-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heroku-api