lib/berkshelf/locations/git_location.rb in berkshelf-3.0.0.beta1 vs lib/berkshelf/locations/git_location.rb in berkshelf-3.0.0.beta2
- old
+ new
@@ -1,17 +1,7 @@
module Berkshelf
- class GitLocation < Location::Base
- class << self
- # Create a temporary directory for the cloned repository within Berkshelf's
- # temporary directory
- #
- # @return [String]
- # the path to the created temporary directory
- def tmpdir
- @tmpdir ||= Berkshelf.mktmpdir
- end
- end
+ class GitLocation < Location::ScmLocation
set_location_key :git
set_valid_options :ref, :branch, :tag, :rel
attr_accessor :uri
@@ -20,11 +10,11 @@
attr_accessor :ref
attr_reader :options
alias_method :tag, :branch
- # @param [Solve::Constraint] version_constraint
+ # @param [Dependency] dependency
# @param [Hash] options
#
# @option options [String] :git
# the Git URL to clone
# @option options [String] :ref
@@ -35,14 +25,14 @@
# same as tag
# @option options [String] :rel
# the path within the repository to find the cookbook
def initialize(dependency, options = {})
super
- @uri = options[:git]
- @branch = options[:branch] || options[:tag] || 'master'
- @ref = options[:ref]
- @rel = options[:rel]
+ @uri = options[:git]
+ @branch = options[:branch] || options[:tag] || 'master'
+ @ref = options[:ref]
+ @rel = options[:rel]
Git.validate_uri!(@uri)
end
# @param [#to_s] destination
@@ -66,10 +56,10 @@
msg << " with ref '#{ref}'" if ref
msg << " at path '#{rel}'" if rel
raise CookbookNotFound, msg
end
- cb_path = File.join(destination, "#{dependency.name}-#{ref}")
+ cb_path = revision_path(destination)
FileUtils.rm_rf(cb_path)
FileUtils.mv(tmp_path, cb_path)
cached = CachedCookbook.from_store_path(cb_path)
validate_cached(cached)