Skip to content
Browse files

Added check to ensure local and remote git HEADs are equal

  • Loading branch information...
1 parent d34b8d8 commit 46ee611137837c7174e40c55695313f40773cce6 Kali Donovan committed Nov 14, 2011
Showing with 16 additions and 3 deletions.
  1. +15 −2 lib/capistrano-conditional/integration.rb
  2. +1 −1 lib/capistrano-conditional/version.rb
View
17 lib/capistrano-conditional/integration.rb
@@ -5,12 +5,25 @@
namespace :conditional do
desc "Initializes the conditional deployment functionality"
task :apply do
- log = capture("cd #{current_path} && git log --format=oneline -n 1", :pty => false)
- ConditionalDeploy.apply_conditions!( log.split[0] )
+ deployed_hash = capture("cd #{current_path} && git log --format=oneline -n 1", :pty => false).split[0]
+ ConditionalDeploy.apply_conditions!( deployed_hash )
+ end
+
+ desc "Tests to be sure that the newest local and remote git commits match"
+ task :ensure_latest_git do
+ remote = capture("cd #{shared_path}/cached-copy && git log --format=oneline -n 1", :pty => false)
+ local = run_locally("git log --format=oneline -n 1")
+
+ unless local == remote
+ abort("\nLocal and remote git repositories have different HEADs:\n Local: #{local} Remote: #{remote}\n Make sure you've committed your latest changes, or else pull down the remote updates and try again\n")
+ end
end
end
# Ensure deploys apply conditional elements before running the rest of the tasks
before 'deploy', 'conditional:apply'
before 'deploy:migrations', 'conditional:apply'
+
+ # Abort deployment if mismatch between local and remote git repositories
+ after 'deploy:update_code', 'conditional:ensure_latest_git'
end
View
2 lib/capistrano-conditional/version.rb
@@ -1,5 +1,5 @@
module Capistrano
module Conditional
- VERSION = "0.0.2"
+ VERSION = "0.0.3"
end
end

0 comments on commit 46ee611

Please sign in to comment.
Something went wrong with that request. Please try again.