Protect yourself from unpushed files

Tagged with Capistrano Ruby

Language: Ruby

View as text

namespace :git do
  task :unpushed do
    ahead = `git log origin/#{branch}..#{branch} --pretty=oneline --abbrev-commit`
    unless ahead == ""
      puts "Whoa, hoss. Looks like you forgot to push the following SHAs:"
      puts ahead
      print "Continue with the deploy anyway? [y/N] "
      if $stdin.gets.chomp.upcase != "Y"
        puts "Good call. `git push` and come back."
        exit
      end
    end
  end
end

before "deploy:update_code", "git:unpushed"
Original snippet written by Michael Ivey
Last updated at 17:43 PM on Feb 02, 2009 by Brian Hogan

SnippetStash costs money to host and develop. The service is free for everyone to use
but if you found it useful please consider making a small donation.