diff options
author | André Arko <andre@arko.net> | 2018-10-20 22:56:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-20 22:56:35 -0700 |
commit | 8a789f00bf5ce93928f0d03ac324387c7d58db46 (patch) | |
tree | 06d312436b909505317124466a5947670e2f8663 | |
parent | f66c3346733afeeff3ac4b09f522fe40bc8dbb44 (diff) | |
parent | 43ffc34dda62c2860d396cd276c99fbcb3ee16b0 (diff) | |
download | bundler-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.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. |