lib/berkshelf/locations/git_location.rb in berkshelf-3.0.0.beta6 vs lib/berkshelf/locations/git_location.rb in berkshelf-3.0.0.beta7

- old
+ new

@@ -66,11 +66,11 @@ Berkshelf::Git.checkout(repo_path, ref || checkout_info[:rev]) @ref = Berkshelf::Git.rev_parse(repo_path) tmp_path = rel ? File.join(repo_path, rel) : repo_path unless File.chef_cookbook?(tmp_path) - msg = "Cookbook '#{dependency.name}' not found at git: #{to_display}" + msg = "Cookbook '#{dependency.name}' not found at #{to_s}" msg << " at path '#{rel}'" if rel raise CookbookNotFound, msg end cb_path = revision_path(destination) @@ -88,21 +88,34 @@ h[:value] = self.uri h[:branch] = self.branch if branch end end + def ==(other) + other.is_a?(GitLocation) && + other.uri == uri && + other.branch == branch && + other.ref == ref && + other.rel == rel + end + def to_s - "#{self.class.location_key}: #{to_display}" + if rel + "#{uri} (at #{branch || ref[0...7]}/#{rel})" + else + "#{uri} (at #{branch || ref[0...7]})" + end end - private + def to_lock + out = " git: #{uri}\n" + out << " branch: #{branch}\n" if branch + out << " ref: #{ref}\n" if ref + out << " rel: #{rel}\n" if rel + out + end - def to_display - info = checkout_info - s = "'#{uri}' with #{info[:kind]}: '#{info[:rev]}'" - s << " at ref: '#{ref}'" if ref && (info[:kind] != "ref" || ref != info[:rev]) - s - end + private def cached?(destination) revision_path(destination) && File.exists?(revision_path(destination)) end