diff options
author | wycats <wycats@gmail.com> | 2010-07-09 13:17:46 -0700 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-07-09 13:17:46 -0700 |
commit | eda732430189d638a8a6cfd9e26031b74be228d4 (patch) | |
tree | 6b79ea0fa28ebfe0e295304ac9b17ad3b2c700e2 | |
parent | d7e1dc1ef387eea787a634382d8f7401bffcdeea (diff) | |
download | bundler-eda732430189d638a8a6cfd9e26031b74be228d4.tar.gz |
Git should never use sudo
-rw-r--r-- | lib/bundler.rb | 10 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source.rb | 26 |
3 files changed, 29 insertions, 9 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 6c0fb990b5..bbec5c2d64 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -126,6 +126,14 @@ module Bundler 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 @@ module Bundler end def tmp - "#{Gem.user_home}/.bundler/tmp" + user_bundle_path.join("tmp") end def settings diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index da6e475e3f..f8644d980a 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -38,7 +38,7 @@ module Bundler return path if path if path = self[:path] - "#{path}/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}" + "#{path}/#{Bundler.ruby_scope}" else Gem.dir end diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index df2277cd00..19d8bfc98a 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -496,7 +496,15 @@ module Bundler 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 @@ module Bundler 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 @@ module Bundler 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 |