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

Add support for a system-wide capistrano config file. Make sure standard recipe loads first. Remove -c/--caprc switch (just use -f).

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@5979 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2007-01-18 04:07:19 +00:00
parent 988fb52df3
commit 55c64d0a9d
2 changed files with 23 additions and 11 deletions

View file

@ -1,5 +1,11 @@
*SVN*
* Removed -c/--caprc switch, since the new load order renders it meaningless (just use -f now) [Mike Bailey]
* Make sure the standard recipe loads first, so that .caprc and friends can override what it defines. [Mike Bailey]
* Add support for a system-wide capistrano config file [Mike Bailey]
* Make cold_deploy call update instead of deploy (to avoid invoking the restart task).
* Make the touch command run by update_code set the TZ to UTC, for consistent setting of asset timestamps. [NeilW]

View file

@ -96,7 +96,7 @@ module Capistrano
def initialize(args = ARGV)
@args = args
@options = { :recipes => [], :actions => [], :vars => {},
:pre_vars => {}, :dotfile => default_dotfile }
:pre_vars => {}, :sysconf => default_sysconf, :dotfile => default_dotfile }
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options] [args]"
@ -109,15 +109,7 @@ module Capistrano
"An action to execute. Multiple actions may",
"be specified, and are loaded in the given order."
) { |value| @options[:actions] << value }
opts.on("-c", "--caprc FILE",
"Specify an alternate personal config file to load.",
"(Default: #{@options[:dotfile]})"
) do |value|
abort "The config file `#{value}' does not exist" unless File.exist?(value)
@options[:dotfile] = value
end
opts.on("-f", "--file FILE",
"A recipe file to load. Multiple recipes may",
"be specified, and are loaded in the given order."
@ -259,10 +251,15 @@ DETAIL
config.set :pretend, options[:pretend]
options[:pre_vars].each { |name, value| config.set(name, value) }
config.load(@options[:dotfile]) if @options[:dotfile] && File.exist?(@options[:dotfile])
# load the standard recipe definition
config.load "standard"
# load systemwide config/recipe definition
config.load(@options[:sysconf]) if @options[:sysconf] && File.exist?(@options[:sysconf])
# load user config/recipe definition
config.load(@options[:dotfile]) if @options[:dotfile] && File.exist?(@options[:dotfile])
options[:recipes].each { |recipe| config.load(recipe) }
options[:vars].each { |name, value| config.set(name, value) }
@ -305,10 +302,19 @@ DETAIL
end
end
def default_sysconf
File.join(sysconf_directory, "capistrano.conf")
end
def default_dotfile
File.join(home_directory, ".caprc")
end
def sysconf_directory
# I'm guessing at where Windows users would keep their conf file.
ENV["SystemRoot"] || '/etc'
end
def home_directory
ENV["HOME"] ||
(ENV["HOMEPATH"] && "#{ENV["HOMEDRIVE"]}#{ENV["HOMEPATH"]}") ||