Permalink
Browse files

Git should never use sudo

  • Loading branch information...
1 parent d7e1dc1 commit eda732430189d638a8a6cfd9e26031b74be228d4 @wycats wycats committed Jul 9, 2010
Showing with 29 additions and 9 deletions.
  1. +9 −1 lib/bundler.rb
  2. +1 −1 lib/bundler/settings.rb
  3. +19 −7 lib/bundler/source.rb
View
@@ -126,6 +126,14 @@ def definition(unlock = nil)
end
end
+ def ruby_scope
+ "#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
+ end
+
+ def user_bundle_path
+ Pathname.new(Gem.user_home).join(".bundler")
+ end
+
def home
bundle_path.join("bundler")
end
@@ -151,7 +159,7 @@ def app_cache
end
def tmp
- "#{Gem.user_home}/.bundler/tmp"
+ user_bundle_path.join("tmp")
end
def settings
View
@@ -38,7 +38,7 @@ def path
return path if path
if path = self[:path]
- "#{path}/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
+ "#{path}/#{Bundler.ruby_scope}"
else
Gem.dir
end
View
@@ -496,7 +496,15 @@ def name
end
def path
- Bundler.install_path.join("#{base_name}-#{shortref_for(revision)}")
+ @install_path ||= begin
+ git_scope = "#{base_name}-#{shortref_for(revision)}"
+
+ if Bundler.requires_sudo?
+ Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope)
+ else
+ Bundler.install_path.join(git_scope)
+ end
+ end
end
def unlock!
@@ -534,11 +542,7 @@ def load_spec_files
private
def git(command)
- if Bundler.requires_sudo?
- out = %x{sudo -E git #{command}}
- else
- out = %x{git #{command}}
- end
+ out = %x{git #{command}}
if $? != 0
raise GitError, "An error has occurred in git. Cannot complete bundling."
@@ -567,7 +571,15 @@ def uri_hash
end
def cache_path
- @cache_path ||= Bundler.cache.join("git", "#{base_name}-#{uri_hash}")
+ @cache_path ||= begin
+ git_scope = "#{base_name}-#{uri_hash}"
+
+ if Bundler.requires_sudo?
+ Bundler.user_bundle_path.join("cache/git", git_scope)
+ else
+ Bundler.cache.join("git", git_scope)
+ end
+ end
end
def cache

0 comments on commit eda7324

Please sign in to comment.