lib/ms_deploy/recipes/defaults.rb in ms_deploy-0.1.6 vs lib/ms_deploy/recipes/defaults.rb in ms_deploy-0.1.7
- old
+ new
@@ -1,64 +1,67 @@
Capistrano::Configuration.instance.load do
- abort "You must run this using 'bundle exec ...'" unless ENV['BUNDLE_BIN_PATH'] || ENV['BUNDLE_GEMFILE']
- abort "You must set :user before using defaults" unless fetch(:user, nil)
- abort "You must set :repository before using defaults" unless fetch(:repository, nil)
- abort "You must set :branch before using defaults" unless fetch(:branch, nil)
- abort "You must set :deploy_to before using defaults" unless fetch(:deploy_to, nil)
+ _cset :keep_releases, 10
+ _cset :use_sudo, false
- set :uptodate_scm, :git
- set :uptodate_branch, fetch(:branch)
- #:uptodate_scm_bynary ('git') - path to SCM binary
- #:uptodate_remote_repository ('origin') - remote repository
- #:uptodate_time (60) - time in seconds for checking remote repository
- #:uptodate_behaviour - (:confirm)
- # :confirm - show outdated message and ask to confirm the further execution
- # :abort - show outdated message and abort further execution
- require 'capistrano/uptodate'
+ _cset :protocol, :both
- require 'capistrano_colors'
- capistrano_color_matchers = [
- { :match => /command finished/, :color => :hide, :prio => 10 },
- { :match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore },
- { :match => /^transaction: commit$/, :color => :magenta, :prio => 10, :attribute => :blink },
- { :match => /git/, :color => :white, :prio => 20, :attribute => :reverse },
- ]
- colorize( capistrano_color_matchers )
+ _cset :scm, :git
+ _cset :git_enable_submodules, true
- #Dynamically skip Capistrano hooks example
- # before 'deploy:update_code', 'db:dump' unless fetch(:skip_dump, false)
- # $ cap staging deploy -S skip_dump=true
-
- set :keep_releases, 10
- set :use_sudo, false
-
- set :group, user
-
- set :protocol, :both
-
- set :scm, :git
- set :git_enable_submodules, true
-
# set deployment strategy
- set :deploy_via, :remote_cache
- set :copy_exclude, %w(.git .svn .DS_Store test doc .gitkeep)
- #set :repository_cache, "cached-copy" # defaults to :shared_path + 'cached-copy/'
+ _cset :deploy_via, :remote_cache
+ _cset :copy_exclude, %w(.git .svn .DS_Store test doc .gitkeep)
+ #_cset :repository_cache, "cached-copy" # defaults to :shared_path + 'cached-copy/'
# :forward_agent allows us to avoid using and distributing a deploy key.
# On problems run 'ssh-add' locally
# In your /etc/ssh/ssh_config or ~/.ssh/config you need to have ForwardAgent enabled for this to work.
- set :ssh_options, {:port => fetch(:ssh_port, 22), :forward_agent => true, :paranoid => true}
+ _cset :ssh_options, {:port => fetch(:ssh_port, 22), :forward_agent => true, :paranoid => true}
default_run_options[:pty] = true
+ task :test_and_prepare_cap_env do
+ abort "You must run this using 'bundle exec ...'" unless ENV['BUNDLE_BIN_PATH'] || ENV['BUNDLE_GEMFILE']
+ abort "You must set :user before using defaults" unless fetch(:user, nil)
+ abort "You must set :repository before using defaults" unless fetch(:repository, nil)
+ abort "You must set :branch before using defaults" unless fetch(:branch, nil)
+ abort "You must set :deploy_to before using defaults" unless fetch(:deploy_to, nil)
+
+ set :uptodate_branch, fetch(:branch)
+ set :uptodate_scm, :git
+ #:uptodate_scm_bynary ('git') - path to SCM binary
+ #:uptodate_remote_repository ('origin') - remote repository
+ #:uptodate_time (60) - time in seconds for checking remote repository
+ #:uptodate_behaviour - (:confirm)
+ # :confirm - show outdated message and ask to confirm the further execution
+ # :abort - show outdated message and abort further execution
+ require 'capistrano/uptodate'
+
+ require 'capistrano_colors'
+ capistrano_color_matchers = [
+ {:match => /command finished/, :color => :hide, :prio => 10},
+ {:match => /executing command/, :color => :blue, :prio => 10, :attribute => :underscore},
+ {:match => /^transaction: commit$/, :color => :magenta, :prio => 10, :attribute => :blink},
+ {:match => /git/, :color => :white, :prio => 20, :attribute => :reverse},
+ ]
+ colorize(capistrano_color_matchers)
+
+ #Dynamically skip Capistrano hooks example
+ # before 'deploy:update_code', 'db:dump' unless fetch(:skip_dump, false)
+ # $ cap staging deploy -S skip_dump=true
+
+ set :group, user
+ end
+
+ before 'deploy', 'test_and_prepare_cap_env'
before 'deploy:setup', 'deploy:prepare:database';
after 'deploy:update', 'deploy:cleanup'
desc "Show currently deployed revision on server."
task :revisions, :roles => :app do
- current, previous, latest = current_revision[0,7], previous_revision[0,7], real_revision[0,7]
+ current, previous, latest = current_revision[0, 7], previous_revision[0, 7], real_revision[0, 7]
puts "\n" << "-"*63
puts "===== Master Revision: \033[1;33m#{latest}\033[0m\n\n"
puts "===== [ \033[1;36m#{application.capitalize} - #{stage.capitalize}\033[0m ]"
puts "=== Deployed Revision: \033[1;32m#{current}\033[0m"
puts "=== Previous Revision: \033[1;32m#{previous}\033[0m\n\n"
@@ -72,10 +75,10 @@
if (diff = `git log #{base_rev}..#{new_rev} --oneline`) != ""
# Colorize refs
diff.gsub!(/^([a-f0-9]+) /, "\033[1;32m\\1\033[0m - ")
diff = " " << diff.gsub("\n", "\n ") << "\n"
# Indent commit messages nicely, max 80 chars per line, line has to end with space.
- diff = diff.split("\n").map{|l|l.scan(/.{1,120}/).join("\n"<<" "*14).gsub(/([^ ]*)\n {14}/m,"\n"<<" "*14<<"\\1")}.join("\n")
+ diff = diff.split("\n").map { |l| l.scan(/.{1,120}/).join("\n"<<" "*14).gsub(/([^ ]*)\n {14}/m, "\n"<<" "*14<<"\\1") }.join("\n")
puts "=== Difference between #{base_label} revision and #{new_label} revision:\n\n"
puts diff
end
end