Sha256: f71a7767539d3e715e4034de23d4cc06bea4bf96e8e5eeef644c760fadae9265

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Braid
  module Commands
    class Setup < Command
      def run(mirror)
        in_work_branch do
          mirror ? setup_one(mirror) : setup_all
        end
      end

      protected
        def setup_all
          msg "Setting up all mirrors."
          config.mirrors.each do |mirror|
            setup_one(mirror)
          end
        end

        def setup_one(mirror)
          params = config.get(mirror)
          unless params
            msg "Mirror '#{mirror}/' does not exist. Skipping."
            return
          end

          if find_remote(params["local_branch"])
            msg "Mirror '#{mirror}/' already has a remote. Skipping."
            return
          end

          msg "Setting up remote for '#{mirror}/'."
          case params["type"]
          when "git"
            invoke(:git_remote_add, params["local_branch"], params["remote"], params["branch"])
          when "svn"
            invoke(:git_svn_init, params["local_branch"], params["remote"])
          end
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evilchelu-braid-0.3.5 lib/braid/commands/setup.rb
evilchelu-braid-0.3.6 lib/braid/commands/setup.rb
evilchelu-braid-0.3.7 lib/braid/commands/setup.rb