Class: SwitchTower::SCM::Cvs
Overview
An SCM module for using CVS as your source control tool. You can specify it by placing the following line in your configuration:
set :scm, :cvs
Also, this module accepts a :cvs
configuration variable, which (if specified) will be used as the full path to the cvs executable on the remote machine:
set :cvs, "/opt/local/bin/cvs"
You can specify the location of your local copy (used to query the revisions, etc.) via the :local
variable, which defaults to “.”.
You may also specify a :branch
configuration variable, which (if specified) will be used in the ‘-r’ option to the cvs check out command. If it is not set, the module will determine if a branch is being used in the CVS sandbox relative to :local
and act accordingly.
set :branch, "prod-20060124"
Also, you can specify the CVS_RSH variable to use on the remote machine(s) via the :cvs_rsh
variable. This defaults to the value of the CVS_RSH environment variable locally, or if it is not set, to “ssh”.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#checkout(actor) ⇒ Object
Check out (on all servers associated with the current task) the latest revision, using a branch if necessary.
-
#current_branch ⇒ Object
Return a string representing the branch that the sandbox relative to
:local
contains. -
#initialize(configuration) ⇒ Cvs
constructor
A new instance of Cvs.
-
#latest_revision ⇒ Object
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 the last revision was made to the repository, so this is a fairly expensive operation…).
Methods inherited from Base
#current_revision, #diff, #update
Constructor Details
#initialize(configuration) ⇒ Cvs
Returns a new instance of Cvs.
34 35 36 37 38 39 40 41 |
# File 'lib/switchtower/scm/cvs.rb', line 34 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 |
Instance Method Details
#checkout(actor) ⇒ Object
Check out (on all servers associated with the current task) the latest revision, using a branch if necessary. Uses the given actor instance to execute the command.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/switchtower/scm/cvs.rb', line 68 def checkout(actor) cvs = configuration[:cvs] || "cvs" cvs_rsh = configuration[:cvs_rsh] || ENV['CVS_RSH'] || "ssh" if "HEAD" == configuration.branch then branch_option = "" else branch_option = "-r #{configuration.branch}" end command = <<-CMD cd #{configuration.releases_path}; CVS_RSH="#{cvs_rsh}" #{cvs} -d #{configuration.repository} -Q co -D "#{configuration.revision}" #{branch_option} -d #{File.basename(actor.release_path)} #{actor.application}; CMD run_checkout(actor, command) do |ch, stream, out| prefix = "#{stream} :: #{ch[:host]}" actor.logger.info out, prefix if out =~ %r{password:} actor.logger.info "CVS is asking for a password", prefix ch.send_data "#{actor.password}\n" elsif out =~ %r{^Enter passphrase} = "CVS needs your key's passphrase and cannot proceed" actor.logger.info , prefix raise end end end |
#current_branch ⇒ Object
Return a string representing the branch that the sandbox relative to :local
contains.
59 60 61 62 63 |
# File 'lib/switchtower/scm/cvs.rb', line 59 def current_branch return @current_branch if @current_branch configuration.logger.debug "determining current_branch..." @current_branch = cvs_branch(cvs_local) end |
#latest_revision ⇒ Object
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 the last revision was made to the repository, so this is a fairly expensive operation…)
47 48 49 50 51 52 53 54 55 |
# File 'lib/switchtower/scm/cvs.rb', line 47 def latest_revision return @latest_revision if @latest_revision configuration.logger.debug "querying latest revision..." @latest_revision = cvs_log(cvs_local, configuration.branch). split(/\r?\n/). grep(/^date: (.*?);/) { Time.parse($1).strftime("%Y-%m-%d %H:%M:%S") }. sort. last end |