Skip to content

Instantly share code, notes, and snippets.

@tomkersten
Created March 1, 2012 23:20
Show Gist options
  • Save tomkersten/1953961 to your computer and use it in GitHub Desktop.
Save tomkersten/1953961 to your computer and use it in GitHub Desktop.
Vlad(/rake) task to let you know what you'd be deploying if you were to do so now...(based off your repo's 'origin' server master branch)
namespace :deploy do
desc "Show which commits would be deployed right now"
remote_task :what do
print "(Locally) Fetching current state of origin..."
`git fetch origin`
origin_master_head = `cat .git/refs/remotes/origin/master`.chomp
origin_head_details = `git log #{origin_master_head} --pretty=oneline -n 1`
puts origin_master_head
print "Current commit on server is..."
production_head = run("cd #{deploy_to} > /dev/null 2>&1 && cat .git/refs/heads/master").chomp
puts ""
if origin_master_head == production_head
puts "Server is in sync with origin/master...no need to deploy"
else
puts "If you deploy now, the following commits will be added to prod:"
puts `git log #{production_head}..#{origin_master_head} --oneline --abbrev-commit`
end
end
end
@tomkersten
Copy link
Author

Use: rake deploy:what (or, rake production deploy:what if you use staged deploys)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment