Sha256: e4aec4b4b5ea0b1f9225bad254fcb8b0a4b9f0690e44981c882310b429a6fba5

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

module Braid
  module Commands
    class Status < Command
      def run(path = nil, options = {})
        path ? status_one(path, options) : status_all(options)
      end

      protected

      def status_all(options = {})
        print "\n"
        msg "Listing all mirrors.\n=======================================================\n"
        config.mirrors.each do |path|
          status_one(path, options)
        end
        print "\n"
      end

      def status_one(path, options = {})
        mirror = config.get!(path)
        setup_remote(mirror)
        mirror.fetch
        print path.to_s
        print ' (' + mirror.base_revision + ')'
        if mirror.locked?
          print ' [REVISION LOCKED]'
        elsif mirror.tag
          print " [TAG=#{mirror.tag}]"
        else # mirror.branch
          print " [BRANCH=#{mirror.branch}]"
        end
        msg "Fetching new commits for '#{mirror.path}'." if verbose?
        new_revision = validate_new_revision(mirror, options['revision'])
        print ' (Remote Modified)' if new_revision.to_s != mirror.base_revision.to_s
        local_file_count = git.read_ls_files(mirror.path).split.size
        if 0 == local_file_count
          print ' (Removed Locally)'
        elsif !mirror.diff.empty?
          print ' (Locally Modified)'
        end
        print "\n"
        clear_remote(mirror, options)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
braid-1.0.22 lib/braid/commands/status.rb
braid-1.0.21 lib/braid/commands/status.rb
braid-1.0.20 lib/braid/commands/status.rb
braid-1.0.19 lib/braid/commands/status.rb
braid-1.0.18 lib/braid/commands/status.rb