Class: Piston::Commands::Status
- Inherits:
-
Piston::Command
- Object
- Piston::Command
- Piston::Commands::Status
- Defined in:
- lib/piston/commands/status.rb
Instance Attribute Summary
Attributes inherited from Piston::Command
#args, #dry_run, #force, #lock, #logging_stream, #quiet, #recursive, #revision, #show_updates, #verbose
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Piston::Command
#find_targets, #initialize, #skip, #svn
Constructor Details
This class inherits a constructor from Piston::Command
Class Method Details
.aliases ⇒ Object
77 78 79 |
# File 'lib/piston/commands/status.rb', line 77 def self.aliases %w(st) end |
.detailed_help ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/piston/commands/status.rb', line 61 def self.detailed_help <<EOF usage: status [DIR [DIR...]] Shows the status of one, many or all pistoned folders. The status is returned in columns. The first column's values are: : Locally unchanged (space) M: Locally modified since importing The second column's values are blanks, unless the --show-updates is passed. M: Remotely modified since importing EOF end |
.help ⇒ Object
57 58 59 |
# File 'lib/piston/commands/status.rb', line 57 def self.help "Determines the current status of each pistoned directory" end |
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/piston/commands/status.rb', line 8 def run # First, find the list of pistoned folders folders = svn(:propget, '--recursive', Piston::ROOT, *args) repos = Hash.new folders.each_line do |line| next unless line =~ /(\w.*) - / repos[$1] = Hash.new end # Then, get their properties repo = nil last_piston_key = nil svn(:proplist, '--verbose', *repos.keys).each_line do |line| case line when /'([^']+)'/ repo = repos[$1] when /(piston:[-\w]+)\s*:\s*(.*)$/ repo[$1] = $2 when /(piston:[-\w]+)\s$/ last_piston_key = $1 when /^\s*(.*)\s*$/ repo[last_piston_key] = $1 if last_piston_key last_piston_key = nil else last_piston_key = nil end end # Determine their local status repos.each_pair do |path, props| log = svn(:log, '--revision', "#{props[Piston::LOCAL_REV]}:HEAD", '--quiet', '--limit', '2', path) props[:locally_modified] = 'M' if log.count("\n") > 3 end # And their remote status, if required repos.values.each do |props| log = svn(:log, '--revision', "#{props[Piston::REMOTE_REV]}:HEAD", '--quiet', '--limit', '2', props[Piston::ROOT]) props[:remotely_modified] = 'M' if log.count("\n") > 3 end if show_updates # Display the results repos.each_pair do |path, props| logging_stream.printf "%1s%1s %5s %s (%s)\n", props[:locally_modified], props[:remotely_modified], props[Piston::LOCKED], path, props[Piston::ROOT] end logging_stream.puts "No pistoned folders found" if repos.empty? end |