Sha256: d0574712020d3f128a5120fb8c307f7b0bd902c9e056b11f9c192f8ea1b28e26

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8
module ProxyTester
  module Actions
    class CloneRepository
      private

      attr_reader :source, :destination, :options 

      public

      def initialize(source, destination, options = {})
        @source               = ::File.expand_path(source)
        @destination          = ::File.expand_path(destination)
        @options            = options
      end

      def run
        if need_to_run? || options[:force] == true
          ProxyTester.ui_logger.warn "Cloning repository from \"#{source}\" to \"#{destination}\"."

          if !need_to_run? && options[:force] == true
            ProxyTester.ui_logger.warn "This action does not support \":force\"-flag. Please move away the destination repository yourself."
            return 
          end

          GitRepository.clone(source, destination, bare: options.fetch(:bare, false))
        else
          ProxyTester.ui_logger.warn "Destination \"#{destination}\" already exists. Do not create it again!"
        end
      end

      private

      def need_to_run?
        !::File.exists? destination
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proxy_tester-0.0.1 lib/proxy_tester/actions/clone_repository.rb