Sha256: 6fd34c765f2197ee8e5d68a54484e41662a5a06d99a8b90350790ad61fac3751

Contents?: true

Size: 910 Bytes

Versions: 3

Compression:

Stored size: 910 Bytes

Contents

module EY
  module Strategies
    class Git
      module Helpers
        def update_repository_cache
          klass = Module.nesting[1]

          strategy = klass.new(
            :repository_cache => c.repository_cache,
            :repo => c.repo,
            :branch => c.branch
          )

          strategy.fetch
          strategy.checkout
        end
      end

      attr_reader :opts

      def initialize(opts)
        @opts = opts
      end

      def fetch
        if File.directory?(File.join(opts[:repository_cache], ".git"))
          `#{git} fetch origin`
        else
          `git clone #{opts[:repo]} #{opts[:repository_cache]}`
        end
      end

      def checkout
         `#{git} reset --hard origin/#{opts[:branch]}`
      end

    private
      def git
        "git --git-dir #{opts[:repository_cache]}/.git --work-tree #{opts[:repository_cache]}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ey-deploy-0.2.4.pre2 lib/ey-deploy/strategies/git.rb
ey-deploy-0.2.4.pre1 lib/ey-deploy/strategies/git.rb
ey-deploy-0.2.4.pre lib/ey-deploy/strategies/git.rb