Sha256: 8844329a6c638ca2a291a33f70803f9b58556075b71542f2b4d6a0201a1f630b

Contents?: true

Size: 953 Bytes

Versions: 5

Compression:

Stored size: 953 Bytes

Contents

module Braid
  module Commands
    class Setup < Command
      def run(path = nil)
        path ? setup_one(path) : setup_all
      end

      protected

      def setup_all
        msg 'Setting up all mirrors.'
        config.mirrors.each do |path|
          setup_one(path)
        end
      end

      def setup_one(path)
        mirror = config.get!(path)

        if git.remote_url(mirror.remote)
          if force?
            msg "Setup: Mirror '#{mirror.path}' already has a remote. Replacing it (force)" if verbose?
            git.remote_rm(mirror.remote)
          else
            msg "Setup: Mirror '#{mirror.path}' already has a remote. Reusing it." if verbose?
            return
          end
        end

        msg "Setup: Creating remote for '#{mirror.path}'." if verbose?
        url = use_local_cache? ? git_cache.path(mirror.url) : mirror.url
        git.remote_add(mirror.remote, url, mirror.branch)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
braid-1.0.15 lib/braid/commands/setup.rb
braid-1.0.14 lib/braid/commands/setup.rb
braid-1.0.13 lib/braid/commands/setup.rb
braid-1.0.12 lib/braid/commands/setup.rb
braid-1.0.11 lib/braid/commands/setup.rb