summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <andre@arko.net>2018-10-20 22:56:35 -0700
committerGitHub <noreply@github.com>2018-10-20 22:56:35 -0700
commit8a789f00bf5ce93928f0d03ac324387c7d58db46 (patch)
tree06d312436b909505317124466a5947670e2f8663
parentf66c3346733afeeff3ac4b09f522fe40bc8dbb44 (diff)
parent43ffc34dda62c2860d396cd276c99fbcb3ee16b0 (diff)
downloadbundler-1-16-stable.tar.gz
Merge pull request #6752 from bundler/indirect/backport-67371-16-stable
backport #6737 to 1-16-stable
-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.