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

git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3340 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
62 lines
1.5 KiB
Ruby
62 lines
1.5 KiB
Ruby
module SwitchTower
|
|
module SCM
|
|
|
|
# The ancestor class of the various SCM module implementations.
|
|
class Base
|
|
attr_reader :configuration
|
|
|
|
def initialize(configuration) #:nodoc:
|
|
@configuration = configuration
|
|
end
|
|
|
|
def latest_revision
|
|
nil
|
|
end
|
|
|
|
def current_revision(actor)
|
|
raise "#{self.class} doesn't support querying the deployed revision"
|
|
end
|
|
|
|
def diff(actor, from=nil, to=nil)
|
|
raise "#{self.class} doesn't support diff(from, to)"
|
|
end
|
|
|
|
def update(actor)
|
|
raise "#{self.class} doesn't support update(actor)"
|
|
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}
|
|
#{logging_commands(directory)}
|
|
fi
|
|
STR
|
|
|
|
actor.run(command, &block)
|
|
end
|
|
|
|
def run_update(actor, guts, &block)
|
|
command = <<-STR
|
|
#{guts}
|
|
#{logging_commands}
|
|
STR
|
|
|
|
actor.run(command, &block)
|
|
end
|
|
|
|
def logging_commands(directory = nil)
|
|
log = "#{configuration.deploy_to}/revisions.log"
|
|
|
|
"echo `date +\"%Y-%m-%d %H:%M:%S\"` $USER #{configuration.revision} #{directory} >> #{log}; " +
|
|
"chmod 666 #{log};"
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|