Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Rewrite of #213 - Commands will be printed only if they are executing on servers #284

wants to merge 1 commit into from

2 participants


Cleaner (IMO) rewrite of #213
I loved the idea, but didn't think it warranted a new DelayedLogger class.

Description from the original pull request:

Capistrano prints all commands even if they really won't be executed, example:

  == Currently executing `deploy:assets:symlink'
  executing "rm -rf /u/apps/appname/releases/20120528203209/public/assets &&\\\n        mkdir -p /u/apps/appname/releases/20120528203209/public &&\\\n        mkdir -p /u/apps/appname/shared/assets &&\\\n        ln -s /u/apps/appname/shared/assets /u/apps/appname/releases/20120528203209/public/assets"
  skipping `deploy:assets:symlink' because no servers matched

after patch:

  == Currently executing `deploy:assets:symlink'
  skipping `deploy:assets:symlink' because no servers matched

@ndbroadbent See the comment I wrote from #213.

@carsomyr carsomyr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/capistrano/configuration/actions/invocation.rb
17 lib/capistrano/configuration/actions/invocation.rb
@@ -159,18 +159,26 @@ def run(cmd, options={}, &block)
# use, but should instead be called indirectly, via #run or #parallel,
# or #invoke_command.
def run_tree(tree, options={}) #:nodoc:
+ # Build a list of log messages to show only if dry_run,
+ # or there are any servers available to execute the command
+ log_before_executing = []
+ show_logs = {|logs| logs.each {|level, message| @logger.send(level, message)}}
if tree.branches.empty? && tree.fallback
- logger.debug "executing #{tree.fallback}"
+ log_before_executing << [:debug, "executing #{tree.fallback}"]
elsif tree.branches.any?
- logger.debug "executing multiple commands in parallel"
+ log_before_executing << [:debug, "executing multiple commands in parallel"]
tree.each do |branch|
- logger.trace "-> #{branch}"
+ log_before_executing << [:trace, "-> #{branch}"]
raise ArgumentError, "attempt to execute without specifying a command"
- return if dry_run || (debug && continue_execution(tree) == false)
+ if dry_run || (debug && continue_execution(tree) == false)
+ show_logs[log_before_executing]
+ return
+ end
options = add_default_command_options(options)
@@ -181,6 +189,7 @@ def run_tree(tree, options={}) #:nodoc:
execute_on_servers(options) do |servers|
+ show_logs[log_before_executing]
targets = { |s| sessions[s] }
Command.process(tree, targets, options.merge(:logger => logger))
Something went wrong with that request. Please try again.