Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lib/bundler/build_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ def self.git_commit_sha
# 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.
Expand Down