Class: Capistrano::SCM::Subversion
- Defined in:
- lib/capistrano/scm/subversion.rb
Overview
An SCM module for using subversion as your source control tool. This module is used by default, but you can explicitly specify it by placing the following line in your configuration:
set :scm, :subversion
Also, this module accepts a :svn
configuration variable, which (if specified) will be used as the full path to the svn executable on the remote machine:
set :svn, "/opt/local/bin/svn"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#checkout(actor) ⇒ Object
Check out (on all servers associated with the current task) the latest revision.
-
#current_revision(actor) ⇒ Object
Return the number of the revision currently deployed.
-
#diff(actor, from = nil, to = nil) ⇒ Object
Return a string containing the diff between the two revisions.
-
#latest_revision ⇒ Object
Return an integer identifying the last known revision in the svn repository.
-
#update(actor) ⇒ Object
Update the current release in-place.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Capistrano::SCM::Base
Instance Method Details
#checkout(actor) ⇒ Object
Check out (on all servers associated with the current task) the latest revision. Uses the given actor instance to execute the command. If svn asks for a password this will automatically provide it (assuming the requested password is the same as the password for logging into the remote server.)
61 62 63 64 65 |
# File 'lib/capistrano/scm/subversion.rb', line 61 def checkout(actor) op = configuration[:checkout] || "co" command = "#{svn} #{op} #{} -q -r#{configuration.revision} #{configuration.repository} #{actor.release_path} &&" run_checkout(actor, command, &svn_stream_handler(actor)) end |
#current_revision(actor) ⇒ Object
Return the number of the revision currently deployed.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/capistrano/scm/subversion.rb', line 30 def current_revision(actor) latest = actor.releases.last grep = %(grep " #{latest}$" #{configuration.deploy_to}/revisions.log) result = "" actor.run(grep, :once => true) do |ch, str, out| result << out if str == :out raise "could not determine current revision" if str == :err end date, time, user, rev, dir = result.split raise "current revision not found in revisions.log" unless dir == latest rev.to_i end |
#diff(actor, from = nil, to = nil) ⇒ Object
Return a string containing the diff between the two revisions. from
and to
may be in any format that svn recognizes as a valid revision identifier. If from
is nil
, it defaults to the last deployed revision. If to
is nil
, it defaults to HEAD.
49 50 51 52 53 54 |
# File 'lib/capistrano/scm/subversion.rb', line 49 def diff(actor, from=nil, to=nil) from ||= current_revision(actor) to ||= "HEAD" `svn diff #{} #{configuration.repository}@#{from} #{configuration.repository}@#{to}` end |
#latest_revision ⇒ Object
Return an integer identifying the last known revision in the svn repository. (This integer is currently the revision number.)
20 21 22 23 24 25 26 27 |
# File 'lib/capistrano/scm/subversion.rb', line 20 def latest_revision @latest_revision ||= begin configuration.logger.debug "querying latest revision..." match = svn_log(configuration.repository).scan(/r(\d+)/).first or raise "Could not determine latest revision" match.first end end |
#update(actor) ⇒ Object
Update the current release in-place. This assumes that the original deployment was made using checkout, and not something like export.
69 70 71 72 |
# File 'lib/capistrano/scm/subversion.rb', line 69 def update(actor) command = "cd #{actor.current_path} && #{svn} up -q &&" run_update(actor, command, &svn_stream_handler(actor)) end |