diff options
| author | Markus Reiter | 2016-10-03 16:12:19 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-10-04 14:45:11 +0200 |
| commit | 23dec587fd26c606e459e72b2987e73bc910a095 (patch) | |
| tree | 269faef30d682247c26d2e6afdd2fc41ece2f138 /Library | |
| parent | cafe1497808ef1ddb002061665ad606aa2340d10 (diff) | |
| download | brew-23dec587fd26c606e459e72b2987e73bc910a095.tar.bz2 | |
Make `core_tap_version_string` reusable.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/brew.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/version.rb | 11 | ||||
| -rw-r--r-- | Library/Homebrew/tap.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 12 |
4 files changed, 14 insertions, 21 deletions
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 4ab360995..a73df50d2 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -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 diff --git a/Library/Homebrew/cask/lib/hbc/version.rb b/Library/Homebrew/cask/lib/hbc/version.rb index 471fd1999..2eb942b95 100644 --- a/Library/Homebrew/cask/lib/hbc/version.rb +++ b/Library/Homebrew/cask/lib/hbc/version.rb @@ -1,13 +1,10 @@ -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 diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index c73e3f7a7..d970a0a37 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -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 = {}) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 04d157262..fbe603b91 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -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 |
