mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Make CVS module's :local value default to "."
git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3612 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
f9a02b4b15
commit
da8480f7b7
3 changed files with 33 additions and 20 deletions
|
@ -1,5 +1,7 @@
|
|||
*0.11.0* *SVN*
|
||||
|
||||
* Make CVS module's :local value default to "."
|
||||
|
||||
* Add "invoke" task for executing one-off commands
|
||||
|
||||
* Make port selection smarter for gateway connections
|
||||
|
|
|
@ -32,13 +32,13 @@ module SwitchTower
|
|||
# CVS_RSH environment variable locally, or if it is not set, to "ssh".
|
||||
class Cvs < Base
|
||||
def initialize(configuration)
|
||||
super(configuration)
|
||||
if not @configuration.respond_to?(:branch) then
|
||||
@configuration.set(:branch) { self.current_branch }
|
||||
else
|
||||
@current_branch = @configuration[:branch]
|
||||
end
|
||||
end
|
||||
super(configuration)
|
||||
if not configuration.respond_to?(:branch) then
|
||||
configuration.set(:branch) { self.current_branch }
|
||||
else
|
||||
@current_branch = configuration[:branch]
|
||||
end
|
||||
end
|
||||
|
||||
# Return a string representing the date of the last revision (CVS is
|
||||
# seriously retarded, in that it does not give you a way to query when
|
||||
|
@ -47,7 +47,7 @@ module SwitchTower
|
|||
def latest_revision
|
||||
return @latest_revision if @latest_revision
|
||||
configuration.logger.debug "querying latest revision..."
|
||||
@latest_revision = cvs_log(configuration.local,configuration.branch).
|
||||
@latest_revision = cvs_log(cvs_local, configuration.branch).
|
||||
split(/\r?\n/).
|
||||
grep(/^date: (.*?);/) { Time.parse($1).strftime("%Y-%m-%d %H:%M:%S") }.
|
||||
sort.
|
||||
|
@ -57,9 +57,9 @@ module SwitchTower
|
|||
# Return a string representing the branch that the sandbox
|
||||
# relative to <tt>:local</tt> contains.
|
||||
def current_branch
|
||||
return @current_branch if @current_branch
|
||||
configuration.logger.debug "determining current_branch..."
|
||||
@current_branch = cvs_branch(configuration.local)
|
||||
return @current_branch if @current_branch
|
||||
configuration.logger.debug "determining current_branch..."
|
||||
@current_branch = cvs_branch(cvs_local)
|
||||
end
|
||||
|
||||
# Check out (on all servers associated with the current task) the latest
|
||||
|
@ -100,20 +100,24 @@ module SwitchTower
|
|||
# and contains a Line starting with 'T' then this CVS sandbox is
|
||||
# 'tagged' with a branch. In the default case return 'HEAD'
|
||||
def cvs_branch(path)
|
||||
branch = "HEAD"
|
||||
branch_file = File.join(path || ".", "CVS", "Tag")
|
||||
if File.exists?(branch_file) then
|
||||
File.open(branch_file) do |f|
|
||||
possible_branch = f.find { |l| l =~ %r{^T} }
|
||||
branch = possible_branch.strip[1..-1] if possible_branch
|
||||
end
|
||||
branch = "HEAD"
|
||||
branch_file = File.join(path || ".", "CVS", "Tag")
|
||||
if File.exists?(branch_file) then
|
||||
File.open(branch_file) do |f|
|
||||
possible_branch = f.find { |l| l =~ %r{^T} }
|
||||
branch = possible_branch.strip[1..-1] if possible_branch
|
||||
end
|
||||
branch
|
||||
end
|
||||
branch
|
||||
end
|
||||
|
||||
def cvs_log(path,branch)
|
||||
`cd #{path || "."} && cvs -q log -N -r#{branch}`
|
||||
end
|
||||
|
||||
def cvs_local
|
||||
configuration.local || "."
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -61,7 +61,6 @@ class ScmCvsTest < Test::Unit::TestCase
|
|||
def setup
|
||||
@config = MockConfiguration.new
|
||||
@config[:repository] = ":ext:joetester@rubyforge.org:/hello/world"
|
||||
@config[:local] = "/hello/world"
|
||||
@config[:cvs] = "/path/to/cvs"
|
||||
@config[:password] = "chocolatebrownies"
|
||||
@config[:now] = Time.utc(2005,8,24,12,0,0)
|
||||
|
@ -149,11 +148,19 @@ MSG
|
|||
end
|
||||
|
||||
def test_latest_revision
|
||||
@config[:local] = "/hello/world"
|
||||
@scm.story = [ @log_msg ]
|
||||
assert_equal "2004-10-12 02:21:02", @scm.latest_revision
|
||||
assert_equal "/hello/world", @scm.last_path
|
||||
end
|
||||
|
||||
def test_latest_with_default_local
|
||||
@config[:local] = nil
|
||||
@scm.story = [ @log_msg ]
|
||||
assert_equal "2004-10-12 02:21:02", @scm.latest_revision
|
||||
assert_equal ".", @scm.last_path
|
||||
end
|
||||
|
||||
def test_checkout
|
||||
@actor.story = []
|
||||
assert_nothing_raised { @scm.checkout(@actor) }
|
||||
|
|
Loading…
Reference in a new issue