Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SwitchTower: log checkouts to a "revisions.log" file

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2060 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 959e06a0fc1dd3b85aeb5d0d005eff2a02eb547e 1 parent b80f0e2
@jamis jamis authored
View
2  switchtower/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Log checkouts to a "revisions.log" file
+
* Changed behavior of checkout to use the timestamp as the release name, instead of the revision number
* Added CVS module (very very experimental!)
View
21 switchtower/lib/switchtower/scm/base.rb
@@ -9,9 +9,26 @@ def initialize(configuration) #:nodoc:
@configuration = configuration
end
- def checkout(actor)
- raise NotImplementedError, "subclasses must implement checkout"
+ def latest_revision
+ nil
end
+
+ private
+
+ def run_checkout(actor, guts, &block)
+ log = "#{configuration.deploy_to}/revisions.log"
+ directory = File.basename(configuration.release_path)
+
+ command = <<-STR
+ if [[ ! -d #{configuration.release_path} ]]; then
+ #{guts}
+ echo `date +"%Y-%m-%d %H:%M:%S"` $USER #{latest_revision} #{directory} >> #{log};
+ chmod 666 #{log};
+ fi
+ STR
+
+ actor.run(command, &block)
+ end
end
end
View
11 switchtower/lib/switchtower/scm/cvs.rb
@@ -44,12 +44,11 @@ def checkout(actor)
cvs_rsh = configuration[:cvs_rsh] || ENV['CVS_RSH'] || "ssh"
command = <<-CMD
- if [[ ! -d #{actor.release_path} ]]; then
- cd #{configuration.releases_path};
- CVS_RSH="#{cvs_rsh}" #{cvs} -d #{configuration.repository} -Q co -D "#{latest_revision}" -d #{File.basename(actor.release_path)} #{actor.application};
- fi
+ cd #{configuration.releases_path};
+ CVS_RSH="#{cvs_rsh}" #{cvs} -d #{configuration.repository} -Q co -D "#{latest_revision}" -d #{File.basename(actor.release_path)} #{actor.application};
CMD
- actor.run(command) do |ch, stream, out|
+
+ run_checkout(actor, command) do |ch, stream, out|
prefix = "#{stream} :: #{ch[:host]}"
actor.logger.info out, prefix
if out =~ %r{password:}
@@ -64,7 +63,7 @@ def checkout(actor)
end
private
-
+
def cvs_log(path)
`cd #{path || "."} && cvs -q log -N -rHEAD`
end
View
8 switchtower/lib/switchtower/scm/darcs.rb
@@ -18,13 +18,7 @@ class Darcs < Base
# revision. Uses the given actor instance to execute the command.
def checkout(actor)
darcs = configuration[:darcs] ? configuration[:darcs] : "darcs"
-
- command = <<-CMD
- if [[ ! -d #{actor.release_path} ]]; then
- #{darcs} get -q --set-scripts-executable #{configuration.repository} #{actor.release_path};
- fi
- CMD
- actor.run(command)
+ run_checkout(actor, "#{darcs} get -q --set-scripts-executable #{configuration.repository} #{actor.release_path};")
end
end
View
13 switchtower/lib/switchtower/scm/subversion.rb
@@ -42,14 +42,9 @@ def latest_revision
def checkout(actor)
svn = configuration[:svn] ? configuration[:svn] : "svn"
- command = <<-CMD
- if [[ -d #{actor.release_path} ]]; then
- #{svn} up -q -r#{latest_revision} #{actor.release_path};
- else
- #{svn} co -q -r#{latest_revision} #{configuration.repository} #{actor.release_path};
- fi
- CMD
- actor.run(command) do |ch, stream, out|
+ command = "#{svn} co -q -r#{latest_revision} #{configuration.repository} #{actor.release_path};"
+
+ run_checkout(actor, command) do |ch, stream, out|
prefix = "#{stream} :: #{ch[:host]}"
actor.logger.info out, prefix
if out =~ /^Password.*:/
@@ -72,7 +67,7 @@ def checkout(actor)
end
private
-
+
def svn_log(path)
`svn log -q -rhead #{path}`
end
View
5 switchtower/test/utils.rb
@@ -22,6 +22,11 @@ def debug(msg,pfx=nil) end
end
class MockConfiguration < Hash
+ def initialize(*args)
+ super
+ self[:release_path] = "/path/to/releases/version"
+ end
+
def logger
@logger ||= MockLogger.new
end
Please sign in to comment.
Something went wrong with that request. Please try again.