Skip to content
Snippets Groups Projects
Commit 23dec587 authored by Markus Reiter's avatar Markus Reiter
Browse files

Make `core_tap_version_string` reusable.

parent cafe1497
No related branches found
No related tags found
No related merge requests found
......@@ -14,8 +14,9 @@ $:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
require "global"
if ARGV == %w[--version] || ARGV == %w[-v]
require "tap"
puts "Homebrew #{HOMEBREW_VERSION}"
puts "Homebrew/homebrew-core #{Homebrew.core_tap_version_string}"
puts "Homebrew/homebrew-core #{CoreTap.instance.version_string}"
exit 0
end
......
HBC_VERSION = "0.60.0".freeze
module Hbc
def self.full_version
@full_version ||= begin
revision, commit = Dir.chdir(Hbc.default_tap.path) do
[`git rev-parse --short=4 --verify -q HEAD 2>/dev/null`.chomp,
`git show -s --format="%cr" HEAD 2>/dev/null`.chomp]
end
"#{HBC_VERSION} (git revision #{revision}; last commit #{commit})"
<<-EOS.undent
Homebrew-Cask #{HOMEBREW_VERSION}
caskroom/homebrew-cask #{Hbc.default_tap.version_string}
EOS
end
end
end
......@@ -138,6 +138,13 @@ class Tap
name
end
def version_string
return "N/A" unless installed?
pretty_revision = git_short_head
return "(no git repository)" unless pretty_revision
"(git revision #{pretty_revision}; last commit #{git_last_commit_date})"
end
# True if this {Tap} is an official Homebrew tap.
def official?
user == "Homebrew"
......@@ -525,7 +532,7 @@ class CoreTap < Tap
end
def self.instance
@instance ||= CoreTap.new
@instance ||= new
end
def self.ensure_installed!(options = {})
......
......@@ -173,18 +173,6 @@ module Homebrew
_system(cmd, *args)
end
def core_tap_version_string
require "tap"
tap = CoreTap.instance
return "N/A" unless tap.installed?
if pretty_revision = tap.git_short_head
last_commit = tap.git_last_commit_date
"(git revision #{pretty_revision}; last commit #{last_commit})"
else
"(no git repository)"
end
end
def install_gem_setup_path!(name, version = nil, executable = name)
# Respect user's preferences for where gems should be installed.
ENV["GEM_HOME"] = ENV["GEM_OLD_HOME"].to_s
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment