Sha256: 81b48718ad7f086d80897489f9cf31d407aac29a5ce02846c1514ad32940c3ee

Contents?: true

Size: 941 Bytes

Versions: 11

Compression:

Stored size: 941 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}'."
        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

11 entries across 11 versions & 1 rubygems

Version Path
braid-1.0.10 lib/braid/commands/setup.rb
braid-1.0.9 lib/braid/commands/setup.rb
braid-1.0.8 lib/braid/commands/setup.rb
braid-1.0.7 lib/braid/commands/setup.rb
braid-1.0.6 lib/braid/commands/setup.rb
braid-1.0.5 lib/braid/commands/setup.rb
braid-1.0.4 lib/braid/commands/setup.rb
braid-1.0.3 lib/braid/commands/setup.rb
braid-1.0.2 lib/braid/commands/setup.rb
braid-1.0.1 lib/braid/commands/setup.rb
braid-1.0.0 lib/braid/commands/setup.rb