Skip to content

Instantly share code, notes, and snippets.

@brynary
Created December 7, 2010 19:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brynary/732229 to your computer and use it in GitHub Desktop.
Save brynary/732229 to your computer and use it in GitHub Desktop.
git:warn_unpushed_changes cap task
Capistrano::Configuration.instance(:must_exist).load do
namespace :git do
task :warn_unpushed_changes do
master_rev = `git rev-parse master`.strip
origin_master_rev = `git rev-parse origin/master`.strip
if master_rev != origin_master_rev
puts "*" * 80
answer = Capistrano::CLI.ui.ask(" You have local commits that have yet to be pushed to origin. Continue? (y/N)")
exit(1) unless answer.downcase == 'y'
end
end
end
before "deploy", "git:warn_unpushed_changes"
before "deploy:migrations", "git:warn_unpushed_changes"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment