mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Add bazaar-ng SCM module [Damien Merenne]
git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3489 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
db39ddc5be
commit
146484da6b
3 changed files with 74 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
*0.11.0* *SVN*
|
*0.11.0* *SVN*
|
||||||
|
|
||||||
|
* Add bazaar-ng SCM module [Damien Merenne]
|
||||||
|
|
||||||
* Add optional :svn_username and :svn_password variables
|
* Add optional :svn_username and :svn_password variables
|
||||||
|
|
||||||
* Allow Proc-valued variables to be set more conveniently (set(:foo) { "bar" })
|
* Allow Proc-valued variables to be set more conveniently (set(:foo) { "bar" })
|
||||||
|
|
3
THANKS
3
THANKS
|
@ -1,2 +1,3 @@
|
||||||
* Bazaar (v1) SCM Module: Edd Dumbill <edd@usefulinc.com>
|
* Bazaar (v1) SCM Module: Edd Dumbill <edd@usefulinc.com>
|
||||||
* Perforce SCM Module: Richard McMahon <richie.mcmahon@gmail.com>
|
* Perforce SCM Module: Richard McMahon <richie.mcmahon@gmail.com>
|
||||||
|
* Bazaar-NG SCM Module: Damien Merenne <dam@capsule.org>
|
70
lib/switchtower/scm/bzr.rb
Normal file
70
lib/switchtower/scm/bzr.rb
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
require 'switchtower/scm/base'
|
||||||
|
|
||||||
|
module SwitchTower
|
||||||
|
module SCM
|
||||||
|
|
||||||
|
# An SCM module for using Bazaar-NG (bzr) as your source control tool.
|
||||||
|
# You can use it by placing the following line in your configuration:
|
||||||
|
#
|
||||||
|
# set :scm, :bzr
|
||||||
|
#
|
||||||
|
# Also, this module accepts a <tt>:bzr</tt> configuration variable,
|
||||||
|
# which (if specified) will be used as the full path to the bzr
|
||||||
|
# executable on the remote machine:
|
||||||
|
#
|
||||||
|
# set :bzr, "/opt/local/bin/bzr"
|
||||||
|
class Bzr < Base
|
||||||
|
# Return an integer identifying the last known revision in the bzr
|
||||||
|
# repository. (This integer is currently the revision number.)
|
||||||
|
def latest_revision
|
||||||
|
`#{bzr} revno #{configuration.repository}`.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
# Return the number of the revision currently deployed.
|
||||||
|
def current_revision(actor)
|
||||||
|
command = "#{bzr} revno #{actor.release_path} &&"
|
||||||
|
run_update(actor, command, &bzr_stream_handler(actor))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Return a string containing the diff between the two revisions. +from+
|
||||||
|
# and +to+ may be in any format that bzr recognizes as a valid revision
|
||||||
|
# identifier. If +from+ is +nil+, it defaults to the last deployed
|
||||||
|
# revision. If +to+ is +nil+, it defaults to the last developed revision.
|
||||||
|
# Pay attention to the fact that as of now bzr does NOT support
|
||||||
|
# diff on remote locations.
|
||||||
|
def diff(actor, from=nil, to=nil)
|
||||||
|
from ||= current_revision(actor)
|
||||||
|
to ||= ""
|
||||||
|
`#{bzr} diff -r #{from}..#{to} #{configuration.repository}`
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check out (on all servers associated with the current task) the latest
|
||||||
|
# revision. Uses the given actor instance to execute the command. If
|
||||||
|
# bzr 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.)
|
||||||
|
def checkout(actor)
|
||||||
|
op = configuration[:checkout] || "branch"
|
||||||
|
command = "#{bzr} #{op} -r#{configuration.revision} #{configuration.repository} #{actor.release_path} &&"
|
||||||
|
run_checkout(actor, command, &bzr_stream_handler(actor))
|
||||||
|
end
|
||||||
|
|
||||||
|
def update(actor)
|
||||||
|
command = "cd #{actor.current_path} && #{bzr} pull -q &&"
|
||||||
|
run_update(actor, command, &bzr_stream_handler(actor))
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def bzr
|
||||||
|
configuration[:bzr] || "bzr"
|
||||||
|
end
|
||||||
|
|
||||||
|
def bzr_stream_handler(actor)
|
||||||
|
Proc.new do |ch, stream, out|
|
||||||
|
prefix = "#{stream} :: #{ch[:host]}"
|
||||||
|
actor.logger.info out, prefix
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue