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

Add optional :svn_username and :svn_password variables

git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3488 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2006-01-28 15:39:51 +00:00
parent 9fd7fc8f19
commit db39ddc5be
3 changed files with 27 additions and 5 deletions

View file

@ -1,5 +1,7 @@
*0.11.0* *SVN*
* Add optional :svn_username and :svn_password variables
* Allow Proc-valued variables to be set more conveniently (set(:foo) { "bar" })
* Add perforce SCM module [Richard McMahon]

View file

@ -68,7 +68,8 @@ module SwitchTower
# remote server.)
def checkout(actor)
op = configuration[:checkout] || "co"
command = "#{svn} #{op} -q -r#{configuration.revision} #{configuration.repository} #{actor.release_path} &&"
username = configuration[:svn_username] ? "--username #{configuration[:svn_username]}" : ""
command = "#{svn} #{op} #{username} -q -r#{configuration.revision} #{configuration.repository} #{actor.release_path} &&"
run_checkout(actor, command, &svn_stream_handler(actor))
end
@ -88,14 +89,18 @@ module SwitchTower
def svn_log(path)
`svn log -q -rhead #{path}`
end
def svn_password
configuration[:svn_password] || configuration[:password]
end
def svn_stream_handler(actor)
Proc.new do |ch, stream, out|
prefix = "#{stream} :: #{ch[:host]}"
actor.logger.info out, prefix
if out =~ /\bpassword.*:/i
actor.logger.info "subversion is asking for a password", prefix
ch.send_data "#{actor.password}\n"
ch.send_data "#{svn_password}\n"
elsif out =~ %r{\(yes/no\)}
actor.logger.info "subversion is asking whether to connect or not",
prefix

View file

@ -84,7 +84,7 @@ MSG
@actor.story = []
assert_nothing_raised { @scm.checkout(@actor) }
assert_nil @actor.channels.last.sent_data
assert_match %r{/path/to/svn}, @actor.command
assert_match %r{/path/to/svn co\s+-q}, @actor.command
end
def test_checkout_via_export
@ -92,7 +92,7 @@ MSG
@config[:checkout] = "export"
assert_nothing_raised { @scm.checkout(@actor) }
assert_nil @actor.channels.last.sent_data
assert_match %r{/path/to/svn export}, @actor.command
assert_match %r{/path/to/svn export\s+-q}, @actor.command
end
def test_update
@ -119,4 +119,19 @@ MSG
assert_nothing_raised { @scm.checkout(@actor) }
assert_equal ["chocolatebrownies\n"], @actor.channels.last.sent_data
end
def test_svn_password
@config[:svn_password] = "butterscotchcandies"
@actor.story = [[:out, "Password: "]]
assert_nothing_raised { @scm.checkout(@actor) }
assert_equal ["butterscotchcandies\n"], @actor.channels.last.sent_data
end
def test_svn_username
@actor.story = []
@config[:svn_username] = "turtledove"
assert_nothing_raised { @scm.checkout(@actor) }
assert_nil @actor.channels.last.sent_data
assert_match %r{/path/to/svn co --username turtledove}, @actor.command
end
end