1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Strip trailing whitespace from all files

(That is [spaceliteraltab] to type a tab on the CLI do Ctrl+v, tab)

    git ls-files | xargs sed -i '' -e 's/[    ]*$//' ]'
This commit is contained in:
Lee Hambley 2013-04-02 20:26:59 +02:00
parent d8325fbb10
commit 4acea20beb
32 changed files with 89 additions and 89 deletions

View file

@ -4,7 +4,7 @@ source "http://rubygems.org"
gemspec
#
# Development Dependencies from the Gemfile
# Development Dependencies from the Gemfile
# are merged here.
#
group :development do

View file

@ -21,7 +21,7 @@ Gem::Specification.new do |s|
]
s.specification_version = 3 if s.respond_to? :specification_version
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<highline>, [">= 0"])
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.14"])

View file

@ -20,7 +20,7 @@ module Capistrano
# Capistrano::CLI.parse(%W(-vvvv -f config/deploy update_code)).execute!
#
# Note that you can also embed cap directly by creating a new Configuration
# instance and setting it up, The above snippet, redone using the
# instance and setting it up, The above snippet, redone using the
# Configuration class directly, would look like:
#
# require 'capistrano'

View file

@ -55,10 +55,10 @@ module Capistrano
def load_recipes(config) #:nodoc:
# load the standard recipe definition
config.load "standard"
# load systemwide config/recipe definition
config.load(options[:sysconf]) if options[:sysconf] && File.file?(options[:sysconf])
config.load(options[:sysconf]) if options[:sysconf] && File.file?(options[:sysconf])
# load user config/recipe definition
config.load(options[:dotfile]) if options[:dotfile] && File.file?(options[:dotfile])

View file

@ -111,14 +111,14 @@ module Capistrano
end
def output_columns #:nodoc:
if ( @output_columns.nil? )
if ( @output_columns.nil? )
if ( self.class.ui.output_cols.nil? )
@output_columns = 80
@output_columns = 80
else
@output_columns = self.class.ui.output_cols
end
end
@output_columns
@output_columns
end
end
end

View file

@ -27,8 +27,8 @@ module Capistrano
def task_call_frames
Thread.current[:task_call_frames] ||= []
end
# The stack of tasks that have registered rollback handlers within the
# current transaction. If this is nil, then there is no transaction
# that is currently active.

View file

@ -141,9 +141,9 @@ module Capistrano
# look to see if this specific configuration instance has ever seen
# these arguments to require before
if @loaded_features.include?(args)
return false
return false
end
@loaded_features << args
begin
original_instance, self.class.instance = self.class.instance, self

View file

@ -68,7 +68,7 @@ module Capistrano
raise ArgumentError, "you must associate a server with at least one role" if roles.empty?
roles.each { |name| role(name, host, options) }
end
def role_names_for_host(host)
roles.map {|role_name, role| role_name if role.include?(host) }.compact || []
end

View file

@ -13,8 +13,8 @@ module Capistrano
# The options hash may include a :hosts option (which should specify
# an array of host names or ServerDefinition instances), a :roles
# option (specifying an array of roles), an :only option (specifying
# a hash of key/value pairs that any matching server must match),
# an :exception option (like :only, but the inverse), and a
# a hash of key/value pairs that any matching server must match),
# an :exception option (like :only, but the inverse), and a
# :skip_hostfilter option to ignore the HOSTFILTER environment variable
# described below.
#
@ -27,7 +27,7 @@ module Capistrano
# will limit the result to hosts found in that (comma-separated) list.
#
# If the HOSTROLEFILTER environment variable is set, it will limit the
# result to hosts found in that (comma-separated) list of roles
# result to hosts found in that (comma-separated) list of roles
#
# Usage:
#
@ -44,9 +44,9 @@ module Capistrano
def find_servers(options={})
return [] if options.key?(:hosts) && (options[:hosts].nil? || [] == options[:hosts])
return [] if options.key?(:roles) && (options[:roles].nil? || [] == options[:roles])
hosts = server_list_from(ENV['HOSTS'] || options[:hosts])
if hosts.any?
if options[:skip_hostfilter]
hosts.uniq
@ -59,7 +59,7 @@ module Capistrano
only = options[:only] || {}
except = options[:except] || {}
# If we don't have a def for a role it means its bogus, skip it so higher level can handle
servers = roles.inject([]) { |list, role| list.concat(self.roles[role] || []) }
servers = servers.select { |server| only.all? { |key,value| server.options[key] == value } }

View file

@ -1,11 +1,11 @@
module Capistrano
Error = Class.new(RuntimeError)
CaptureError = Class.new(Capistrano::Error)
NoSuchTaskError = Class.new(Capistrano::Error)
NoMatchingServersError = Class.new(Capistrano::Error)
class RemoteError < Error
attr_accessor :hosts
end
@ -13,7 +13,7 @@ module Capistrano
ConnectionError = Class.new(Capistrano::RemoteError)
TransferError = Class.new(Capistrano::RemoteError)
CommandError = Class.new(Capistrano::RemoteError)
LocalArgumentError = Class.new(Capistrano::Error)
end

View file

@ -39,7 +39,7 @@ Capistrano::Configuration.instance.load do
else
abort "No stage specified. Please specify one of: #{stages.join(', ')} (e.g. `cap #{stages.first} #{ARGV.last}')"
end
end
end
end
desc "Stub out the staging config files."

View file

@ -18,7 +18,7 @@ module Capistrano
yield self
self
end
def remote
dep = RemoteDependency.new(configuration)
@dependencies << dep

View file

@ -58,31 +58,31 @@ module Capistrano
def match(command, expect, options={})
expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp)
output_per_server = {}
try("#{command} ", options) do |ch, stream, out|
output_per_server[ch[:server]] ||= ''
output_per_server[ch[:server]] += out
end
output_per_server = {}
try("#{command} ", options) do |ch, stream, out|
output_per_server[ch[:server]] ||= ''
output_per_server[ch[:server]] += out
end
# It is possible for some of these commands to return a status != 0
# (for example, rake --version exits with a 1). For this check we
# just care if the output matches, so we reset the success flag.
@success = true
errored_hosts = []
output_per_server.each_pair do |server, output|
errored_hosts = []
output_per_server.each_pair do |server, output|
next if output =~ expect
errored_hosts << server
end
errored_hosts << server
end
if errored_hosts.any?
@hosts = errored_hosts.join(', ')
output = output_per_server[errored_hosts.first]
@message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}"
@success = false
end
end
self
self
end
def or(message)

View file

@ -14,9 +14,9 @@ module Capistrano
# * :repository - This should match the depot that code lives in. If your code
# exists in a subdirectory, you can append the path depot.
# eg. foo-depot/bar_dir
# * :stream - The stream in the depot that code should be pulled from. If
# * :stream - The stream in the depot that code should be pulled from. If
# left blank, the depot stream will be used
# * :revision - Should be in the form 'stream/transaction'.
# * :revision - Should be in the form 'stream/transaction'.
class Accurev < Base
include REXML
default_command 'accurev'
@ -54,10 +54,10 @@ module Capistrano
end
end
# Pops a copy of the code for the specified Accurev revision identifier.
# Pops a copy of the code for the specified Accurev revision identifier.
# The revision identifier is represented as a stream & transaction ID combo.
# Accurev can only pop a particular transaction if a stream is created on the server
# with a time basis of that transaction id. Therefore, we will create a stream with
# with a time basis of that transaction id. Therefore, we will create a stream with
# the required criteria and pop that.
def export(revision_id, destination)
revision = InternalRevision.parse(revision_id)
@ -89,7 +89,7 @@ module Capistrano
].join(' | ')
end
# Returns the command needed to show the diff between what is deployed and what is
# Returns the command needed to show the diff between what is deployed and what is
# pending. Because Accurev can not do this task without creating some streams,
# two time basis streams will be created for the purposes of doing the diff.
def diff(from, to=head)
@ -156,7 +156,7 @@ module Capistrano
end
def to_s
"#{stream}/#{transaction_id}"
"#{stream}/#{transaction_id}"
end
def ==(other)

View file

@ -63,7 +63,7 @@ module Capistrano
scm cvs_root, :log, range_arg
end
# Unfortunately, cvs doesn't support the concept of a revision number like
# Unfortunately, cvs doesn't support the concept of a revision number like
# subversion and other SCM's do. For now, we'll rely on getting the timestamp
# of the latest checkin under the revision that's passed to us.
def query_revision(revision)
@ -99,7 +99,7 @@ module Capistrano
root << "-d #{repository} " if repository
root
end
# Constructs the destination dir command-line option
def cvs_destination(destination)
dest = ""
@ -109,7 +109,7 @@ module Capistrano
end
dest
end
# attempts to guess what type of revision we're working with
def revision_type(rev)
return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} UTC$/ # i.e 2007-05-15 08:13:25 UTC
@ -117,7 +117,7 @@ module Capistrano
return :revision if rev =~ /^\d/ # i.e. 1.2.1
return :tag # i.e. RELEASE_1_2
end
# constructs the appropriate command-line switch for specifying a
# "revision" in CVS. This could be a tag, branch, revision (i.e. 1.3)
# or a date (to be used with -d)

View file

@ -25,13 +25,13 @@ module Capistrano
"--to-match='hash #{revision}'"
end
end
# Returns the command that will check out the given revision to the
# given destination. The 'revision' parameter must be the 'hash' value
# for the revision in question, as given by 'darcs changes --xml-output'.
def checkout(revision, destination)
scm :get, *[verbose,
"--repo-name=#{destination}",
scm :get, *[verbose,
"--repo-name=#{destination}",
to_match(revision),
repository].compact
end

View file

@ -133,7 +133,7 @@ module Capistrano
git = command
remote = origin
args = []
args = []
# Add an option for the branch name so :git_shallow_clone works with branches
args << "-b #{variable(:branch)}" unless variable(:branch).nil?

View file

@ -89,11 +89,11 @@ module Capistrano
"yes\n"
end
end
private
# Fine grained mercurial commands
def clone(destination)
def clone(destination)
scm :clone,
verbose,
"--noupdate", # do not update to tip when cloning is done
@ -124,7 +124,7 @@ module Capistrano
else "--verbose"
end
end
# honor Cap 2.1+'s :scm_prefer_prompt if present
def scm_password_or_prompt
@scm_password_or_prompt ||= variable(:scm_password) ||

View file

@ -19,7 +19,7 @@ module Capistrano
# set :scm, :none
# set :deploy_via, :copy
#
# Dereference symbolic links. Copy files instead. Handy when you
# Dereference symbolic links. Copy files instead. Handy when you
# reference files and directory outside of your deployment root.
# set :copy_dereference_symlink, true
@ -41,13 +41,13 @@ module Capistrano
def query_revision(revision)
revision
end
# log: There's no log, so it just echos from and to.
def log(from="", to="")
"No SCM: #{from} - #{to}"
end
end
end

View file

@ -113,7 +113,7 @@ module Capistrano
def p4passwd
variable(:p4passwd) || variable(:scm_password)
end
def p4charset
variable(:p4charset)
end

View file

@ -70,7 +70,7 @@ module Capistrano
port = server.port || options[:port] || ssh_options[:port]
# the .ssh/config file might have changed the host-name on us
host = ssh_options.fetch(:host_name, server.host)
host = ssh_options.fetch(:host_name, server.host)
ssh_options[:port] = port if port

View file

@ -23,7 +23,7 @@ class CLIOptionsTest < Test::Unit::TestCase
@cli.expects(:exit).raises(ExitException)
assert_raises(ExitException) { @cli.parse_options! }
end
def test_parse_options_with_d_should_set_debug_option
@cli.args << "-d"
@cli.parse_options!

View file

@ -126,7 +126,7 @@ class ConfigurationCallbacksTest < Test::Unit::TestCase
assert_equal 1, @config.callbacks[:before].length
assert_equal %w(primary), @config.callbacks[:before].first.except
end
def test_on_without_tasks_or_block_should_raise_error
assert_raises(ArgumentError) { @config.on(:before) }
end

View file

@ -146,7 +146,7 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
def test_parent_for_namespace_should_be_the_top_level
@config.namespace(:outer) {}
assert_equal @config, @config.namespaces[:outer].parent
assert_equal @config, @config.namespaces[:outer].parent
end
def test_fqn_for_nested_namespace_should_be_color_delimited
@ -238,7 +238,7 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
ns = @config.namespaces[:outer]
assert ns.respond_to?(:original_initialize_called)
end
def test_namespace_should_accept_respond_to_with_include_priv_parameter
@config.namespace(:outer) {}
ns = @config.namespaces[:outer]
@ -308,16 +308,16 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
end
assert_nil @config.find_task("outer::inner")
end
def test_kernel_method_clashing_should_not_affect_method_delegation_to_parent
@config.class.class_eval do
def some_weird_method() 'config' end
end
@config.namespace(:clash) {}
namespace = @config.namespaces[:clash]
assert_equal 'config', namespace.some_weird_method
Kernel.module_eval do
def some_weird_method() 'kernel' end
end
@ -325,7 +325,7 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
@config.namespace(:clash2) {}
namespace = @config.namespaces[:clash2]
assert_equal 'config', namespace.some_weird_method
Kernel.send :remove_method, :some_weird_method
@config.class.send :remove_method, :some_weird_method
end

View file

@ -21,14 +21,14 @@ class ConfigurationRolesTest < Test::Unit::TestCase
assert @config.original_initialize_called
assert @config.roles.empty?
end
def test_roles_for_host_with_one_role
@config.role :app, "app1.capistrano.test"
@config.role :not_app, "not-app.capistrano.test"
app_server = @config.roles[:app].servers.first
assert @config.role_names_for_host(app_server)==[ :app ]
end
def test_roles_for_host_with_multiple_roles
@config.server "www.capistrano.test", :db, :worker
db_server = @config.roles[:db].servers.first

View file

@ -163,7 +163,7 @@ class ConfigurationServersTest < Test::Unit::TestCase
assert_equal %w(app1 app2 app3), @config.find_servers(:roles => lambda { :app }).map { |s| s.host }.sort
assert_equal %w(app2 file), @config.find_servers(:roles => lambda { [:report, :file] }).map { |s| s.host }.sort
end
def test_find_servers_with_hosts_nil_or_empty
assert_equal [], @config.find_servers(:hosts => nil)
assert_equal [], @config.find_servers(:hosts => [])
@ -172,12 +172,12 @@ class ConfigurationServersTest < Test::Unit::TestCase
result = @config.find_servers(:hosts => "app1")
assert_equal 1, result.size
end
def test_find_servers_with_rolees_nil_or_empty
assert_equal [], @config.find_servers(:roles => nil)
assert_equal [], @config.find_servers(:roles => [])
result = @config.find_servers(:roles => :report)
assert_equal 1, result.size
end
end

View file

@ -53,13 +53,13 @@ class ConfigurationVariablesTest < Test::Unit::TestCase
@config[:sample] = :value
assert @config.respond_to?(:sample)
end
def test_respond_to_should_be_true_when_passed_a_string
assert !@config.respond_to?('sample')
@config[:sample] = :value
assert @config.respond_to?('sample')
end
def test_respond_to_with_include_priv_paramter
assert !@config.respond_to?(:sample, true)
end

View file

@ -41,7 +41,7 @@ class DeploySCMBzrTest < Test::Unit::TestCase
'before:revid:aaaa@bbbb-1234567890',
'last:3',
nil, {}, [], true, false, 1.34, ]
revision_samples.each do |revivsion_spec|
assert_equal(revivsion_spec,
@source.query_revision(revivsion_spec),

View file

@ -15,7 +15,7 @@ class DeploySCMDarcsTest < Test::Unit::TestCase
# We should be able to pick a specific hash.
def test_checkout_hash
hsh = "*version_hash*"
assert_match(%r{--to-match=.hash #{Regexp.quote(hsh)}},
assert_match(%r{--to-match=.hash #{Regexp.quote(hsh)}},
@source.checkout(hsh, "*foo_location*"),
"Specifying a revision hash got the --to-match option wrong.")
end
@ -31,7 +31,7 @@ class DeploySCMDarcsTest < Test::Unit::TestCase
# Leaving the revision as nil shouldn't break anything.
def test_checkout_nil
assert_no_match(%r{--to-match}, @source.checkout(nil, "*foo_location*"),
"Leaving the revision as nil incorrectly produced a --to-match option.")
"Leaving the revision as nil incorrectly produced a --to-match option.")
end
end

View file

@ -62,19 +62,19 @@ class DeploySCMMercurialTest < Test::Unit::TestCase
@config[:scm_command] = "/opt/local/bin/hg"
assert_equal "/opt/local/bin/hg pull --repository /var/www && /opt/local/bin/hg update --repository /var/www --clean 8a8e00b8f11b", @source.sync('8a8e00b8f11b', dest)
end
def test_export
dest = "/var/www"
assert_raise(NotImplementedError) { @source.export('8a8e00b8f11b', dest) }
end
def test_sends_password_if_set
require 'capistrano/logger'
text = "password:"
@config[:scm_password] = "opensesame"
assert_equal "opensesame\n", @source.handle_data(mock_state, :test_stream, text)
end
def test_prompts_for_password_if_preferred
require 'capistrano/logger'
require 'capistrano/cli'

View file

@ -62,11 +62,11 @@ class ServerDefinitionTest < Test::Unit::TestCase
server = Capistrano::ServerDefinition.new("www.capistrano.test", :primary => true)
assert_equal true, server.options[:primary]
end
def test_default_user_should_try_to_guess_username
ENV.stubs(:[]).returns(nil)
assert_equal "not-specified", Capistrano::ServerDefinition.default_user
ENV.stubs(:[]).returns(nil)
ENV.stubs(:[]).with("USERNAME").returns("ryan")
assert_equal "ryan", Capistrano::ServerDefinition.default_user

View file

@ -67,7 +67,7 @@ class ShellTest < Test::Unit::TestCase
@shell.expects(:process_command).with("on", "app,db", "hello world")
assert @shell.read_and_execute
end
def test_task_command_with_bang_gets_processed_by_exec_tasks
while_testing_post_exec_commands do
@shell.expects(:read_line).returns("!deploy")
@ -75,7 +75,7 @@ class ShellTest < Test::Unit::TestCase
assert @shell.read_and_execute
end
end
def test_normal_command_gets_processed_by_exec_command
while_testing_post_exec_commands do
@shell.expects(:read_line).returns("uptime")
@ -84,13 +84,13 @@ class ShellTest < Test::Unit::TestCase
assert @shell.read_and_execute
end
end
private
def while_testing_post_exec_commands(&block)
@shell.instance_variable_set(:@mutex,Mutex.new)
yield
end
end