Class: Piston::Commands::Update
- Defined in:
- lib/piston/commands/update.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#run(wcdir, to) ⇒ Object
wcdir
is the working copy we’re going to change. - #start(*args) ⇒ Object
Methods inherited from Base
#force, #guess_wc, #initialize, logger, #logger, #quiet, #verbose, #working_copy!
Constructor Details
This class inherits a constructor from Piston::Commands::Base
Instance Method Details
#run(wcdir, to) ⇒ Object
wcdir
is the working copy we’re going to change. to
is the new target revision we want to be at after update returns.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/piston/commands/update.rb', line 8 def run(wcdir, to) working_copy = working_copy!(wcdir) logger.debug {"Recalling previously saved values"} values = working_copy.recall return "#{wcdir} is locked: not updating" if values["lock"] repository = working_copy.repository from_revision = repository.at(values["handler"]) to_revision = repository.at(to) to_revision.resolve! logger.debug {"Validating that #{from_revision} exists and is capable of performing the update"} from_revision.validate! logger.info {"Updating from #{from_revision} to #{to_revision}"} changed = working_copy.update(from_revision, to_revision, [:lock]) if changed then logger.info {"Updated #{wcdir} to #{to_revision}"} else logger.info {"Upstream #{repository} was unchanged from #{from_revision}"} end end |
#start(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/piston/commands/update.rb', line 33 def start(*args) args.flatten.map {|d| Pathname.new(d).}.each do |wcdir| begin run(wcdir, [:revision] || [:commit] || :head) rescue Piston::WorkingCopy::NotWorkingCopy puts "#{wcdir} is not a working copy" end end end |