diff options
author | André Arko <andre@arko.net> | 2018-10-20 22:56:35 -0700 |
---|---|---|
committer | SHIBATA Hiroshi <hsbt@ruby-lang.org> | 2018-11-21 15:28:45 +0900 |
commit | 2e50ece287ca89cf8126049a536a1b6cd6d11005 (patch) | |
tree | 5c57ee6436d55db2f67ca48b68ea890785c3b9f8 | |
parent | 2760d72d3b2a1070b279536c33d3a89aaad7426b (diff) | |
download | bundler-2e50ece287ca89cf8126049a536a1b6cd6d11005.tar.gz |
Merge pull request #6752 from bundler/indirect/backport-6737
backport #6737 to 1-16-stable
(cherry picked from commit 8a789f00bf5ce93928f0d03ac324387c7d58db46)
-rw-r--r-- | lib/bundler/build_metadata.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/bundler/build_metadata.rb b/lib/bundler/build_metadata.rb index a0428f0319..33f91e9162 100644 --- a/lib/bundler/build_metadata.rb +++ b/lib/bundler/build_metadata.rb @@ -28,12 +28,19 @@ module Bundler # If Bundler has been installed without its .git directory and without a # commit instance variable then we can't determine its commits SHA. git_dir = File.join(File.expand_path("../../..", __FILE__), ".git") - return "unknown" unless File.directory?(git_dir) + if File.directory?(git_dir) + return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze } + end - # Otherwise shell out to git. - @git_commit_sha = Dir.chdir(File.expand_path("..", __FILE__)) do - `git rev-parse --short HEAD`.strip.freeze + # If Bundler is a submodule in RubyGems, get the submodule commit + git_sub_dir = File.join(File.expand_path("../../../..", __FILE__), ".git") + if File.directory?(git_sub_dir) + return @git_commit_sha = Dir.chdir(git_sub_dir) do + `git ls-tree --abbrev=8 HEAD bundler`.split(/\s/).fetch(2, "").strip.freeze + end end + + @git_commit_sha ||= "unknown" end # Whether this is an official release build of Bundler. |