summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <andre@arko.net>2018-10-20 22:56:35 -0700
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2018-11-21 15:29:52 +0900
commit7e2ac2853bf88224fed9bff44d51356112bb1c06 (patch)
treeb72c45d89721bf5c49f625eef91cc4b376974960
parentfd2ae038bf0a6ce8cbf5ef38134db9fb71e9b632 (diff)
downloadbundler-7e2ac2853bf88224fed9bff44d51356112bb1c06.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.rb15
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.