Sha256: 36ef60f5e80d45bd5242f6c1e93052828e91b0d7f89380ff3288e5d6e3c904cf

Contents?: true

Size: 947 Bytes

Versions: 5

Compression:

Stored size: 947 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

5 entries across 5 versions & 1 rubygems

Version Path
realityforge-braid-0.9.3 lib/braid/commands/setup.rb
realityforge-braid-0.9.2 lib/braid/commands/setup.rb
realityforge-braid-0.9.1 lib/braid/commands/setup.rb
realityforge-braid-0.9.0 lib/braid/commands/setup.rb
realityforge-braid-0.8.0 lib/braid/commands/setup.rb