heroku-bartender 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,3 +3,4 @@ require "heroku/bartender/log"
3
3
  require "heroku/bartender/command"
4
4
  require "heroku/bartender/server"
5
5
  require "heroku/bartender/version"
6
+ require "heroku/bartender/sandbox"
@@ -21,11 +21,8 @@ module Heroku
21
21
  def self.move_to release, predeploy, heroku_remote
22
22
  @@last_error = nil
23
23
  if predeploy && ! predeploy.strip.empty?
24
- rc = system(predeploy)
25
- if rc.nil? || ! rc
26
- raise "Error executing pre-deploy command '#{predeploy}': #{$?}"
27
- end
28
- end
24
+ Sandbox.new(release).predeploy(predeploy.strip)
25
+ end
29
26
  repo = Grit::Repo.new('.')
30
27
  if ! repo.remote_list.include?(heroku_remote)
31
28
  raise "No such remote `#{heroku_remote}`"
@@ -0,0 +1,42 @@
1
+ require 'tmpdir'
2
+ require 'fileutils'
3
+ module Heroku
4
+ module Bartender
5
+ class Sandbox
6
+
7
+ attr_accessor :sha, :name, :current_dir, :sandbox_dir
8
+
9
+ def initialize(sha)
10
+ @sha = sha
11
+ @name = gen_sandbox_name
12
+ @sandbox_dir = "#{Dir.tmpdir}/#{@name}/"
13
+ @current_dir = "#{Dir.pwd}/"
14
+ end
15
+
16
+ def predeploy(command)
17
+ copy_current_repo_to_me
18
+ Dir.chdir(@sandbox_dir) do
19
+ `git checkout #{@sha}`
20
+ rc = system(command)
21
+ if rc.nil? || ! rc
22
+ raise "Error executing pre-deploy command '#{command}': #{$?}"
23
+ end
24
+ end
25
+ end
26
+
27
+ private
28
+ def random
29
+ rand(Time.now.to_i)
30
+ end
31
+
32
+ def gen_sandbox_name
33
+ "bartender-sandbox-#{random}-#{@sha[0..7]}"
34
+ end
35
+
36
+ def copy_current_repo_to_me
37
+ FileUtils.cp_r @current_dir, @sandbox_dir
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,5 @@
1
1
  module Heroku
2
2
  module Bartender
3
- VERSION = '0.4.1'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-bartender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-15 00:00:00.000000000Z
12
+ date: 2011-08-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2156095960 !ruby/object:Gem::Requirement
16
+ requirement: &2156521100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2156095960
24
+ version_requirements: *2156521100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rack-test
27
- requirement: &2156095360 !ruby/object:Gem::Requirement
27
+ requirement: &2156520640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2156095360
35
+ version_requirements: *2156520640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: grit
38
- requirement: &2156094760 !ruby/object:Gem::Requirement
38
+ requirement: &2156520020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.4.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2156094760
46
+ version_requirements: *2156520020
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sinatra
49
- requirement: &2156094120 !ruby/object:Gem::Requirement
49
+ requirement: &2156519500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.2.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2156094120
57
+ version_requirements: *2156519500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: choice
60
- requirement: &2156093560 !ruby/object:Gem::Requirement
60
+ requirement: &2156519040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.1.4
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2156093560
68
+ version_requirements: *2156519040
69
69
  description: Ruby gem to handle releases in heroku.
70
70
  email: sebastianarcila@gmail.com
71
71
  executables:
@@ -92,6 +92,7 @@ files:
92
92
  - lib/heroku/bartender/public/javascript/jquery-1.5.1.min.js
93
93
  - lib/heroku/bartender/public/stylesheets/application.css
94
94
  - lib/heroku/bartender/public/stylesheets/reset.css
95
+ - lib/heroku/bartender/sandbox.rb
95
96
  - lib/heroku/bartender/server.rb
96
97
  - lib/heroku/bartender/version.rb
97
98
  - lib/heroku/bartender/views/template.erb