Skip to content

Instantly share code, notes, and snippets.

@soutaro
Created July 28, 2011 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soutaro/1111375 to your computer and use it in GitHub Desktop.
Save soutaro/1111375 to your computer and use it in GitHub Desktop.
Ensure your remote branch is up to date
set :deploy_via, :remote_cache
set :branch, "release"
namespace :git do
namespace :ensure do
desc "Check if your local branch is synched with remote branch"
task :pushed do
local = `git rev-parse #{branch}`.chomp
remote = `git rev-parse remotes/origin/#{branch}`.chomp
unless local == remote
abort "ABORTING:: You have local commits\n\t#{branch} => #{local}\n\tremotes/origin/#{branch} => #{remote}"
end
end
end
end
before :deploy, "git:ensure:pushed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment