Sha256: 3b2763fae25e2be3a7ab2d086cfa2b0afb313eef2fe19b72a1583a7c2cba50a5
Contents?: true
Size: 1.7 KB
Versions: 10
Compression:
Stored size: 1.7 KB
Contents
class PushDeploy EMPTY_DIR = '4b825dc642cb6eb9a060e54bf8d69288fbee4904' def initialize(args, &block) puts 'Running auto_deploy...' @deploy_to = args[3] @oldrev, @newrev = args.shift, args.shift || 'HEAD' if @oldrev == '0000000000000000000000000000000000000000' @oldrev = EMPTY_DIR elsif @oldrev.nil? @oldrev = '@{-1}' end instance_exec(&block) end def bundle return if @oldrev == '0' return unless File.exist?('Gemfile') if %x{git diff --name-only #{@oldrev} #{@newrev}} =~ /^Gemfile|\.gemspec$/ begin # If Bundler in turn spawns Git, it can get confused by $GIT_DIR git_dir = ENV.delete('GIT_DIR') run "bundle check" unless $?.success? puts "Bundling..." run "bundle | grep -v '^Using ' | grep -v ' is complete'" end ensure ENV['GIT_DIR'] = git_dir end end end def run(command) Kernel.system "#{command} >&1" end def migrate return if @oldrev == '0' schema = %x{git diff --name-status #{@oldrev} #{@newrev} -- db/schema.rb} if schema =~ /^A/ run "bundle exec rake db:create" end if `git diff HEAD^`.index("db/migrate") puts "Migrating.." run 'bundle exec rake db:migrate RAILS_ENV="production"' end end end
Version data entries
10 entries across 10 versions & 1 rubygems