From 0775f9032e14aeb1993819a7160d63c58a114ea0 Mon Sep 17 00:00:00 2001 From: Tray Torrance Date: Mon, 14 Nov 2011 10:35:19 -0800 Subject: [PATCH 1/4] Refactors require statements --- config/deploy.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index 7930c0b2f..d1ad6a854 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -5,6 +5,8 @@ set :config_yaml, YAML.load_file(File.dirname(__FILE__) + '/deploy_config.yml') require 'bundler/capistrano' +require './config/boot' +require 'hoptoad_notifier/capistrano' set :bundle_dir, '' set :stages, ['production', 'staging'] @@ -88,5 +90,3 @@ end after "deploy:symlink", "deploy:symlink_config_files", "deploy:symlink_cookie_secret", "deploy:bundle_static_assets", 'deploy:copy_resque_assets' - require './config/boot' - require 'hoptoad_notifier/capistrano' From 76d31f3110a7fdbdeda33e04079d3e9e9d3bff6d Mon Sep 17 00:00:00 2001 From: Tray Torrance Date: Mon, 14 Nov 2011 11:01:39 -0800 Subject: [PATCH 2/4] Hooks current_git_branch to before deploy:update Also refactors after deploy:symlink hooks --- config/deploy.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index d1ad6a854..cdb1f8aac 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -32,9 +32,6 @@ def current_git_branch branch end -# Set the deploy branch to the current branch -set :branch, current_git_branch - namespace :deploy do task :symlink_config_files do run "ln -s -f #{shared_path}/config/database.yml #{current_path}/config/database.yml" @@ -88,5 +85,14 @@ namespace :deploy do end end -after "deploy:symlink", "deploy:symlink_config_files", "deploy:symlink_cookie_secret", "deploy:bundle_static_assets", 'deploy:copy_resque_assets' +before 'deploy:update' do + set :branch, current_git_branch +end + +after 'deploy:symlink' do + deploy.symlink_config_files + deploy.symlink_cookie_secret + deploy.bundle_static_assets + deploy.copy_resque_assets +end From bbc165137f7aff3e9ac88c8716eabf59dd36830a Mon Sep 17 00:00:00 2001 From: Tray Torrance Date: Mon, 14 Nov 2011 11:07:14 -0800 Subject: [PATCH 3/4] Adds capistrano_colors gem; deprecates custom red method Also adjusts current_git_branch to use Capistrano's logger for printing to STDOUT --- Gemfile | 1 + Gemfile.lock | 2 ++ config/deploy.rb | 8 ++------ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 2efbc6983..9724db6da 100644 --- a/Gemfile +++ b/Gemfile @@ -138,6 +138,7 @@ end group :development do gem 'capistrano', '2.5.19', :require => false + gem 'capistrano_colors', :require => false gem 'capistrano-ext', '1.2.1', :require => false gem 'linecache', '0.43', :platforms => :mri_18 gem 'parallel_tests' diff --git a/Gemfile.lock b/Gemfile.lock index fd73dbd54..7cfa16026 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,6 +104,7 @@ GEM net-ssh-gateway (>= 1.0.0) capistrano-ext (1.2.1) capistrano (>= 1.0.0) + capistrano_colors (0.5.5) capybara (0.3.9) culerity (>= 0.2.4) mime-types (>= 1.16) @@ -478,6 +479,7 @@ DEPENDENCIES bundler (>= 1.0.0) capistrano (= 2.5.19) capistrano-ext (= 1.2.1) + capistrano_colors capybara (~> 0.3.9) carrierwave (= 0.5.3) chef (= 0.9.12) diff --git a/config/deploy.rb b/config/deploy.rb index cdb1f8aac..44ab9053c 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -4,6 +4,7 @@ set :config_yaml, YAML.load_file(File.dirname(__FILE__) + '/deploy_config.yml') +require './config/cap_colors' require 'bundler/capistrano' require './config/boot' require 'hoptoad_notifier/capistrano' @@ -20,15 +21,10 @@ set :scm_verbose, true set :repository_cache, "remote_cache" set :deploy_via, :checkout -# Bonus! Colors are pretty! -def red(str) - "\e[31m#{str}\e[0m" -end - # Figure out the name of the current local branch def current_git_branch branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\/heads\//, '') - puts "Deploying branch #{red branch}" + logger.info "Deploying branch #{branch}" branch end From c46c07f648abd8357da3852422d826c684fbb4e1 Mon Sep 17 00:00:00 2001 From: Tray Torrance Date: Tue, 15 Nov 2011 09:06:15 -0800 Subject: [PATCH 4/4] Added color definition file at config/cap_colors.rb --- config/cap_colors.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 config/cap_colors.rb diff --git a/config/cap_colors.rb b/config/cap_colors.rb new file mode 100644 index 000000000..e5ca5516f --- /dev/null +++ b/config/cap_colors.rb @@ -0,0 +1,11 @@ +require 'capistrano_colors' + +capistrano_color_matchers = [ + # Full docs at https://github.com/stjernstrom/capistrano_colors/ + # Any priority above 0 will override capistrano_colors' defaults if needed + { :match => /^Deploying branch/, :color => :yellow, :prio => 20 }, +] + +capistrano_color_matchers.each do |matcher| + Capistrano::Logger::add_color_matcher( matcher ) +end