Skip to content

Commit

Permalink
Merge pull request #12 from nevinera/master
Browse files Browse the repository at this point in the history
Use the appropriate syntax for 'heroku rake' on cedar apps
  • Loading branch information
cldwalker committed Jul 31, 2012
2 parents b44f1ad + 266b2d0 commit 8f40d4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion lib/heroku-rails/config.rb
Expand Up @@ -40,6 +40,14 @@ def stack(app_env)
stacks[app_env] || stacks['all']
end

def rake_cmd(app_env)
if self.stack(app_env) =~ /cedar/i
'heroku run rake'
else
'heroku rake'
end
end

# pull out the config setting hash for a particular app environment
def config(app_env)
config = self.settings['config'] || {}
Expand Down Expand Up @@ -75,4 +83,4 @@ def app_setting_list(setting_key, app)
(all + (setting[app] || [])).uniq
end
end
end
end
9 changes: 6 additions & 3 deletions lib/heroku/rails/tasks.rb
Expand Up @@ -62,10 +62,12 @@ def system_with_echo(*args)
Rake::Task["heroku:before_each_deploy"].reenable
Rake::Task["heroku:before_each_deploy"].invoke(app_name)

rake_cmd = HEROKU_CONFIG.rake_cmd(heroku_env)

branch = `git branch`.scan(/^\* (.*)\n/).flatten.first.to_s
if branch.present?
@git_push_arguments ||= []
system_with_echo "git push #{repo} #{@git_push_arguments.join(' ')} #{branch}:master && heroku rake --app #{app_name} db:migrate && heroku restart --app #{app_name}"
system_with_echo "git push #{repo} #{@git_push_arguments.join(' ')} #{branch}:master && #{rake_cmd} --app #{app_name} db:migrate && heroku restart --app #{app_name}"
else
puts "Unable to determine the current git branch, please checkout the branch you'd like to deploy"
exit(1)
Expand Down Expand Up @@ -179,7 +181,8 @@ def system_with_echo(*args)
desc "Migrates and restarts remote servers"
task :migrate do
HEROKU_RUNNER.each_heroku_app do |heroku_env, app_name, repo|
system_with_echo "heroku rake --app #{app_name} db:migrate && heroku restart --app #{app_name}"
rake_cmd = HEROKU_CONFIG.rake_cmd(heroku_env)
system_with_echo "#{rake_cmd} --app #{app_name} db:migrate && heroku restart --app #{app_name}"
end
end

Expand All @@ -200,4 +203,4 @@ def system_with_echo(*args)
end
end
end
end
end

0 comments on commit 8f40d4a

Please sign in to comment.