lib/berkshelf/locations/git_location.rb in berkshelf-1.4.1 vs lib/berkshelf/locations/git_location.rb in berkshelf-1.4.2
- old
+ new
@@ -18,10 +18,11 @@
set_valid_options :ref, :branch, :tag, :rel
attr_accessor :uri
attr_accessor :branch
attr_accessor :rel
+ attr_accessor :branch_name
attr_reader :options
alias_method :ref, :branch
alias_method :tag, :branch
@@ -41,12 +42,13 @@
# the path within the repository to find the cookbook
def initialize(name, version_constraint, options = {})
@name = name
@version_constraint = version_constraint
@uri = options[:git]
- @branch = options[:branch] || options[:ref] || options[:tag]
+ @branch = options[:branch] || options[:ref] || options[:tag] || "master"
@rel = options[:rel]
+ @branch_name = @branch.gsub("-", "_").gsub("/", "__") # In case the remote is specified
Git.validate_uri!(@uri)
end
# @param [#to_s] destination
@@ -59,25 +61,27 @@
unless branch
self.branch = ::Berkshelf::Git.rev_parse(clone)
end
tmp_path = rel ? File.join(clone, rel) : clone
+ puts "File.chef_cookbook?(tmp_path): #{File.chef_cookbook?(tmp_path)}"
unless File.chef_cookbook?(tmp_path)
msg = "Cookbook '#{name}' not found at git: #{uri}"
msg << " with branch '#{branch}'" if branch
msg << " at path '#{rel}'" if rel
raise CookbookNotFound, msg
end
-
- cb_path = File.join(destination, "#{self.name}-#{Git.rev_parse(clone)}")
+
+ cb_path = File.join(destination, "#{name}-#{branch_name}")
FileUtils.rm_rf(cb_path)
FileUtils.mv(tmp_path, cb_path)
-
+
cached = CachedCookbook.from_store_path(cb_path)
validate_cached(cached)
set_downloaded_status(true)
+ puts "cached.class: #{cached.class}"
cached
end
def to_hash
super.tap do |h|
@@ -119,9 +123,9 @@
return cached
end
def revision_path(destination)
return unless branch
- File.join(destination, "#{name}-#{branch}")
+ File.join(destination, "#{name}-#{branch_name}")
end
end
end