Skip to content

Commit cfc9f75

Browse files
committed
Merge pull request #1541 from mattbrictson/airbrussh
Make Airbrussh the default formatter for Capistrano
2 parents 79d9e84 + a65713f commit cfc9f75

File tree

11 files changed

+48
-70
lines changed

11 files changed

+48
-70
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ Reverse Chronological Order:
66

77
https://github.com/capistrano/capistrano/compare/v3.4.0...HEAD
88

9+
**You'll notice a big cosmetic change in this release: the default logging
10+
format has been changed to
11+
[Airbrussh](https://github.com/mattbrictson/airbrussh).** For more details on
12+
what Airbrussh does
13+
and how to configure it, visit the
14+
[Airbrussh README](https://github.com/mattbrictson/airbrussh#readme). To opt out
15+
of the new format, simply add `set :format, :pretty` to switch to the old
16+
default of Capistrano 3.4.0 and earlier.
17+
18+
Other changes:
19+
920
* `remove` DSL method for removing values like from arrays like `linked_dirs`
1021
* `append` DSL method for pushing values like `linked_dirs`
1122
[#1447](https://github.com/capistrano/capistrano/pull/1447),

capistrano.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ Gem::Specification.new do |gem|
2020
gem.licenses = ['MIT']
2121

2222
gem.required_ruby_version = '>= 1.9.3'
23-
gem.add_dependency 'sshkit', '>= 1.7.1'
24-
gem.add_dependency 'rake', '>= 10.0.0'
23+
gem.add_dependency 'airbrussh', '>= 1.0.0.beta1'
2524
gem.add_dependency 'i18n'
25+
gem.add_dependency 'rake', '>= 10.0.0'
26+
gem.add_dependency 'sshkit', '>= 1.9.0.rc1'
2627

2728
gem.add_development_dependency 'rspec'
2829
gem.add_development_dependency 'mocha'

lib/capistrano/configuration.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ def fetch(key, default=nil, &block)
5858
return value
5959
end
6060

61+
def any?(key)
62+
value = fetch(key)
63+
if value && value.respond_to?(:any?)
64+
value.any?
65+
else
66+
!fetch(key).nil?
67+
end
68+
end
69+
6170
def validate(key, &validator)
6271
vs = (validators[key] || [])
6372
vs << validator
@@ -105,7 +114,7 @@ def backend
105114

106115
def configure_backend
107116
backend.configure do |sshkit|
108-
sshkit.format = fetch(:format)
117+
configure_sshkit_output(sshkit)
109118
sshkit.output_verbosity = fetch(:log_level)
110119
sshkit.default_env = fetch(:default_env)
111120
sshkit.backend = fetch(:sshkit_backend, SSHKit::Backend::Netssh)
@@ -182,5 +191,12 @@ def invoke_validations(key, value, &block)
182191
validator.call(key, block || value)
183192
end
184193
end
194+
195+
def configure_sshkit_output(sshkit)
196+
format_args = [fetch(:format)]
197+
format_args.push(fetch(:format_options)) if any?(:format_options)
198+
199+
sshkit.use_format(*format_args)
200+
end
185201
end
186202
end

lib/capistrano/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
set_if_empty :default_env, {}
1717
set_if_empty :keep_releases, 5
1818

19-
set_if_empty :format, :pretty
19+
set_if_empty :format, :airbrussh
2020
set_if_empty :log_level, :debug
2121

2222
set_if_empty :pty, false

lib/capistrano/dsl/env.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ def is_question?(key)
1313
end
1414

1515
def any?(key)
16-
value = fetch(key)
17-
if value && value.respond_to?(:any?)
18-
value.any?
19-
else
20-
!fetch(key).nil?
21-
end
16+
env.any?(key)
2217
end
2318

2419
def roles(*names)

lib/capistrano/ext/sshkit/backend/thread_local.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/capistrano/plugin.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require "capistrano/all"
2-
require "capistrano/ext/sshkit/backend/thread_local"
32
require "rake/tasklib"
43

54
# Base class for Capistrano plugins. Makes building a Capistrano plugin as easy

lib/capistrano/setup.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
end
88
end
99

10+
require "airbrussh/capistrano"
11+
# We don't need to show the "using Airbrussh" banner announcement since
12+
# Airbrussh is now the built-in formatter. Also enable command output by
13+
# default; hiding the output might be confusing to users new to Capistrano.
14+
Airbrussh.configure do |airbrussh|
15+
airbrussh.banner = false
16+
airbrussh.command_output = true
17+
end
18+
1019
stages.each do |stage|
1120
Rake::Task.define_task(stage) do
1221
set(:stage, stage.to_sym)

lib/capistrano/templates/deploy.rb.erb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ set :repo_url, '[email protected]:me/my_repo.git'
1313
# Default value for :scm is :git
1414
# set :scm, :git
1515

16-
# Default value for :format is :pretty
17-
# set :format, :pretty
16+
# Default value for :format is :airbrussh.
17+
# set :format, :airbrussh
1818

19-
# Default value for :log_level is :debug
20-
# set :log_level, :debug
19+
# You can configure the Airbrussh format using :format_options.
20+
# These are the defaults.
21+
# set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto
2122

2223
# Default value for :pty is false
2324
# set :pty, true

spec/lib/capistrano/ext/sshkit/backend/thread_local_spec.rb

Lines changed: 0 additions & 30 deletions
This file was deleted.

spec/support/test_app.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def default_config
1717
server 'vagrant@localhost:2220', roles: %w{web app}
1818
set :linked_files, #{linked_files}
1919
set :linked_dirs, #{linked_dirs}
20+
set :format_options, log_file: nil
2021
}
2122
end
2223

0 commit comments

Comments
 (0)