diff options
author | t ddddddd <miscmisc@cmme.org> | 2013-12-01 19:43:14 -0800 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2013-12-20 10:32:01 -0800 |
commit | d1349e19a295d5798cd5f5bd0bdf4d491eab4372 (patch) | |
tree | c676ea711fde4dd78c94d4dd95786c467fc42a1d | |
parent | bc5e659235b7b1ef0558d045ee81b97ed86df61a (diff) | |
download | bundler-d1349e19a295d5798cd5f5bd0bdf4d491eab4372.tar.gz |
Ensure that Gem::Specification#git_version can be called safely in a repo with no commits.
-rw-r--r-- | lib/bundler/rubygems_ext.rb | 10 | ||||
-rw-r--r-- | lib/bundler/source/git/git_proxy.rb | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 9f50d9621b..6661d2039c 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -57,7 +57,9 @@ module Gem def git_version if @loaded_from && File.exist?(File.join(full_gem_path, ".git")) - sha = Bundler::SharedHelpers.chdir(full_gem_path){ `git rev-parse HEAD`.strip } + sha = Bundler::SharedHelpers.chdir(full_gem_path) do + null_command("git rev-parse HEAD").strip + end " #{sha[0..6]}" end end @@ -94,6 +96,12 @@ module Gem gemfile end + # TODO: Do not rely on /dev/null. + # see https://github.com/bundler/bundler/blob/98f79a1d/lib/bundler/source/git/git_proxy.rb#L97-101 + def null_command(command) + `#{command} 2>#{Bundler::NULL}`.tap {|out| return `#{command}` if out.empty? } + end + end class Dependency diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 7d8b5d404b..a059a7cf89 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -101,11 +101,7 @@ module Bundler # If it doesn't, everything will work fine, but the user # will get the $stderr messages as well. def git_null(command) - if !Bundler::WINDOWS && File.exist?("/dev/null") - git("#{command} 2>/dev/null", false) - else - git(command, false) - end + git("#{command} 2>#{Bundler::NULL}", false) end def git(command, check_errors=true) |