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

Make sure variables are conditionally set in the deploy recipes, so as not to clobber values set elsewhere (closes #8938)

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@7203 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2007-07-21 21:27:57 +00:00
parent 54af9ca4f0
commit cdb38cd287
2 changed files with 30 additions and 22 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Make sure variables are conditionally set in the deploy recipes, so as not to clobber values set elsewhere [Jamis Buck]
* Fix "input stream is empty" errors from HighLine on prompt [Jamis Buck]
* Added "synchronous_connect" setting to try and work around SFTP hangs for certain users [Jamis Buck]

View file

@ -2,24 +2,30 @@ require 'yaml'
require 'capistrano/recipes/deploy/scm'
require 'capistrano/recipes/deploy/strategy'
def _cset(name, *args, &block)
unless exists?(name)
set(name, *args, &block)
end
end
# =========================================================================
# These variables MUST be set in the client capfiles. If they are not set,
# the deploy will fail with an error.
# =========================================================================
set(:application) { abort "Please specify the name of your application, set :application, 'foo'" }
set(:repository) { abort "Please specify the repository that houses your application's code, set :repository, 'foo'" }
_cset(:application) { abort "Please specify the name of your application, set :application, 'foo'" }
_cset(:repository) { abort "Please specify the repository that houses your application's code, set :repository, 'foo'" }
# =========================================================================
# These variables may be set in the client capfile if their default values
# are not sufficient.
# =========================================================================
set :scm, :subversion
set :deploy_via, :checkout
_cset :scm, :subversion
_cset :deploy_via, :checkout
set(:deploy_to) { "/u/apps/#{application}" }
set(:revision) { source.head } unless exists?(:revision)
_cset(:deploy_to) { "/u/apps/#{application}" }
_cset(:revision) { source.head }
# =========================================================================
# These variables should NOT be changed unless you are very confident in
@ -27,33 +33,33 @@ set(:revision) { source.head } unless exists?(:revision)
# changes if you do decide to muck with these!
# =========================================================================
set(:source) { Capistrano::Deploy::SCM.new(scm, self) }
set(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { `#{cmd}` } } }
_cset(:source) { Capistrano::Deploy::SCM.new(scm, self) }
_cset(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { `#{cmd}` } } }
set(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) }
_cset(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) }
set(:release_name) { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") }
set(:releases_path) { File.join(deploy_to, "releases") }
set(:shared_path) { File.join(deploy_to, "shared") }
set(:current_path) { File.join(deploy_to, "current") }
set(:release_path) { File.join(releases_path, release_name) }
_cset(:release_name) { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") }
_cset(:releases_path) { File.join(deploy_to, "releases") }
_cset(:shared_path) { File.join(deploy_to, "shared") }
_cset(:current_path) { File.join(deploy_to, "current") }
_cset(:release_path) { File.join(releases_path, release_name) }
set(:releases) { capture("ls -x #{releases_path}").split.sort }
set(:current_release) { File.join(releases_path, releases.last) }
set(:previous_release) { File.join(releases_path, releases[-2]) }
_cset(:releases) { capture("ls -x #{releases_path}").split.sort }
_cset(:current_release) { File.join(releases_path, releases.last) }
_cset(:previous_release) { File.join(releases_path, releases[-2]) }
set(:current_revision) { capture("cat #{current_path}/REVISION").chomp }
set(:latest_revision) { capture("cat #{current_release}/REVISION").chomp }
set(:previous_revision) { capture("cat #{previous_release}/REVISION").chomp }
_cset(:current_revision) { capture("cat #{current_path}/REVISION").chomp }
_cset(:latest_revision) { capture("cat #{current_release}/REVISION").chomp }
_cset(:previous_revision) { capture("cat #{previous_release}/REVISION").chomp }
set(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
_cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
# some tasks, like symlink, need to always point at the latest release, but
# they can also (occassionally) be called standalone. In the standalone case,
# the timestamped release_path will be inaccurate, since the directory won't
# actually exist. This variable lets tasks like symlink work either in the
# standalone case, or during deployment.
set(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
_cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
# =========================================================================
# These are helper methods that will be available to your recipes.