pushdeploy 0.0.14 → 0.0.15

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.
@@ -0,0 +1,58 @@
1
+ class PushDeploy
2
+
3
+ EMPTY_DIR = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
4
+
5
+ def initialize(args, &block)
6
+
7
+ puts 'Running auto_deploy...'
8
+
9
+ @deploy_to = args[3]
10
+
11
+ @oldrev, @newrev = args.shift, args.shift || 'HEAD'
12
+ if @oldrev == '0000000000000000000000000000000000000000'
13
+ @oldrev = EMPTY_DIR
14
+ elsif @oldrev.nil?
15
+ @oldrev = '@{-1}'
16
+ end
17
+
18
+ instance_exec(&block)
19
+
20
+ end
21
+
22
+ def bundle
23
+ return if @oldrev == '0'
24
+
25
+ return unless File.exist?('Gemfile')
26
+ if %x{git diff --name-only #{@oldrev} #{@newrev}} =~ /^Gemfile|\.gemspec$/
27
+ begin
28
+ # If Bundler in turn spawns Git, it can get confused by $GIT_DIR
29
+ git_dir = ENV.delete('GIT_DIR')
30
+ run "bundle check"
31
+ unless $?.success?
32
+ puts "Bundling..."
33
+ run "bundle | grep -v '^Using ' | grep -v ' is complete'"
34
+ end
35
+ ensure
36
+ ENV['GIT_DIR'] = git_dir
37
+ end
38
+ end
39
+ end
40
+
41
+ def run(command)
42
+ Kernel.system "#{command} >&1"
43
+ end
44
+
45
+ def migrate
46
+ return if @oldrev == '0'
47
+
48
+ schema = %x{git diff --name-status #{@oldrev} #{@newrev} -- db/schema.rb}
49
+ if schema =~ /^A/
50
+ run "bundle exec rake db:create"
51
+ end
52
+
53
+ if `git diff HEAD^`.index("db/migrate")
54
+ puts "Migrating.."
55
+ run 'bundle exec rake db:migrate RAILS_ENV="production"'
56
+ end
57
+ end
58
+ end
@@ -1,3 +1,3 @@
1
1
  module Pushdeploy
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pushdeploy
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.14
5
+ version: 0.0.15
6
6
  platform: ruby
7
7
  authors:
8
8
  - Artem Yankov
@@ -34,6 +34,7 @@ files:
34
34
  - config/after_deploy.rb
35
35
  - hooks/post-receive
36
36
  - lib/pushdeploy.rb
37
+ - lib/pushdeploy/pushdeploy.rb
37
38
  - lib/pushdeploy/version.rb
38
39
  - pushdeploy.gemspec
39
40
  homepage: ""