Skip to content
Extraits de code Groupes Projets
Valider 908d0b99 rédigé par Daniel Grippi's avatar Daniel Grippi
Parcourir les fichiers

Merge pull request #2404 from torrancew/capistrano_colorized

Capistrano colorized
parents 8a275682 c46c07f6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -138,6 +138,7 @@ end ...@@ -138,6 +138,7 @@ end
group :development do group :development do
gem 'capistrano', '2.5.19', :require => false gem 'capistrano', '2.5.19', :require => false
gem 'capistrano_colors', :require => false
gem 'capistrano-ext', '1.2.1', :require => false gem 'capistrano-ext', '1.2.1', :require => false
gem 'linecache', '0.43', :platforms => :mri_18 gem 'linecache', '0.43', :platforms => :mri_18
gem 'parallel_tests' gem 'parallel_tests'
......
...@@ -104,6 +104,7 @@ GEM ...@@ -104,6 +104,7 @@ GEM
net-ssh-gateway (>= 1.0.0) net-ssh-gateway (>= 1.0.0)
capistrano-ext (1.2.1) capistrano-ext (1.2.1)
capistrano (>= 1.0.0) capistrano (>= 1.0.0)
capistrano_colors (0.5.5)
capybara (0.3.9) capybara (0.3.9)
culerity (>= 0.2.4) culerity (>= 0.2.4)
mime-types (>= 1.16) mime-types (>= 1.16)
...@@ -478,6 +479,7 @@ DEPENDENCIES ...@@ -478,6 +479,7 @@ DEPENDENCIES
bundler (>= 1.0.0) bundler (>= 1.0.0)
capistrano (= 2.5.19) capistrano (= 2.5.19)
capistrano-ext (= 1.2.1) capistrano-ext (= 1.2.1)
capistrano_colors
capybara (~> 0.3.9) capybara (~> 0.3.9)
carrierwave (= 0.5.3) carrierwave (= 0.5.3)
chef (= 0.9.12) chef (= 0.9.12)
......
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
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
set :config_yaml, YAML.load_file(File.dirname(__FILE__) + '/deploy_config.yml') set :config_yaml, YAML.load_file(File.dirname(__FILE__) + '/deploy_config.yml')
require './config/cap_colors'
require 'bundler/capistrano' require 'bundler/capistrano'
require './config/boot'
require 'hoptoad_notifier/capistrano'
set :bundle_dir, '' set :bundle_dir, ''
set :stages, ['production', 'staging'] set :stages, ['production', 'staging']
...@@ -18,21 +21,13 @@ set :scm_verbose, true ...@@ -18,21 +21,13 @@ set :scm_verbose, true
set :repository_cache, "remote_cache" set :repository_cache, "remote_cache"
set :deploy_via, :checkout 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 # Figure out the name of the current local branch
def current_git_branch def current_git_branch
branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\/heads\//, '') branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\/heads\//, '')
puts "Deploying branch #{red branch}" logger.info "Deploying branch #{branch}"
branch branch
end end
# Set the deploy branch to the current branch
set :branch, current_git_branch
namespace :deploy do namespace :deploy do
task :symlink_config_files do task :symlink_config_files do
run "ln -s -f #{shared_path}/config/database.yml #{current_path}/config/database.yml" run "ln -s -f #{shared_path}/config/database.yml #{current_path}/config/database.yml"
...@@ -86,7 +81,14 @@ namespace :deploy do ...@@ -86,7 +81,14 @@ namespace :deploy do
end end
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
require './config/boot'
require 'hoptoad_notifier/capistrano'
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter