lib/bundler/source.rb in bundler-1.0.0.rc.6 vs lib/bundler/source.rb in bundler-1.0.0
- old
+ new
@@ -127,10 +127,17 @@
def add_remote(source)
@remotes << normalize_uri(source)
end
+ def merge_remotes(source)
+ @remotes = []
+ source.remotes.each do |r|
+ add_remote r.to_s
+ end
+ end
+
private
def cached_gem(spec)
possibilities = @caches.map { |p| "#{p}/#{spec.full_name}.gem" }
possibilities.find { |p| File.exist?(p) }
@@ -463,11 +470,11 @@
end
def to_lock
out = "GIT\n"
out << " remote: #{@uri}\n"
- out << " revision: #{shortref_for(revision)}\n"
+ out << " revision: #{revision}\n"
%w(ref branch tag submodules).each do |opt|
out << " #{opt}: #{options[opt]}\n" if options[opt]
end
out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
out << " specs:\n"
@@ -483,21 +490,21 @@
end
alias == eql?
def to_s
- ref = @options["ref"] ? shortref_for(@options["ref"]) : @ref
+ ref = @options["ref"] ? shortref_for_display(@options["ref"]) : @ref
"#{@uri} (at #{ref})"
end
def name
File.basename(@uri, '.git')
end
def path
@install_path ||= begin
- git_scope = "#{base_name}-#{shortref_for(revision)}"
+ git_scope = "#{base_name}-#{shortref_for_path(revision)}"
if Bundler.requires_sudo?
Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope)
else
Bundler.install_path.join(git_scope)
@@ -556,14 +563,18 @@
def base_name
File.basename(uri.sub(%r{^(\w+://)?([^/:]+:)},''), ".git")
end
- def shortref_for(ref)
+ def shortref_for_display(ref)
ref[0..6]
end
+ def shortref_for_path(ref)
+ ref[0..11]
+ end
+
def uri_hash
if uri =~ %r{^\w+://(\w+@)?}
# Downcase the domain component of the URI
# and strip off a trailing slash, if one is present
input = URI.parse(uri).normalize.to_s.sub(%r{/$},'')
@@ -602,11 +613,11 @@
unless File.exist?(path.join(".git"))
FileUtils.mkdir_p(path.dirname)
git %|clone --no-checkout "#{cache_path}" "#{path}"|
end
Dir.chdir(path) do
- git "fetch --force --quiet '#{cache_path}'"
+ git %|fetch --force --quiet "#{cache_path}"|
git "reset --hard #{revision}"
if @submodules
git "submodule init"
git "submodule update"
@@ -614,10 +625,10 @@
end
end
def has_revision_cached?
return unless @revision
- in_cache { git %|rev-parse --verify --quiet #{@revision}| }
+ in_cache { git %|cat-file -e #{@revision}| }
true
rescue GitError
false
end