aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_integration_cmds.rb2
-rw-r--r--Library/Homebrew/utils.rb18
-rwxr-xr-xLibrary/brew.rb4
3 files changed, 21 insertions, 3 deletions
diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb
index 7594bd87f..19a2372d7 100644
--- a/Library/Homebrew/test/test_integration_cmds.rb
+++ b/Library/Homebrew/test/test_integration_cmds.rb
@@ -40,7 +40,7 @@ class IntegrationCommandTests < Homebrew::TestCase
end
def test_version
- assert_equal HOMEBREW_VERSION.to_s,
+ assert_match HOMEBREW_VERSION.to_s,
cmd("--version")
end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 1390db14e..63cdaadfa 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -147,10 +147,28 @@ module Homebrew
HOMEBREW_REPOSITORY.cd { `git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle }
end
+ def self.git_short_head
+ HOMEBREW_REPOSITORY.cd { `git rev-parse --short=4 --verify -q HEAD 2>/dev/null`.chuzzle }
+ end
+
def self.git_last_commit
HOMEBREW_REPOSITORY.cd { `git show -s --format="%cr" HEAD 2>/dev/null`.chuzzle }
end
+ def self.git_last_commit_date
+ HOMEBREW_REPOSITORY.cd { `git show -s --format="%cd" --date=short HEAD 2>/dev/null`.chuzzle }
+ end
+
+ def self.homebrew_version_string
+ pretty_revision = git_short_head
+ if pretty_revision
+ last_commit = git_last_commit_date
+ "#{HOMEBREW_VERSION} (git revision #{pretty_revision}; last commit #{last_commit})"
+ else
+ "#{HOMEBREW_VERSION} (no git repository)"
+ end
+ end
+
def self.install_gem_setup_path!(gem, version = nil, executable = gem)
require "rubygems"
ENV["PATH"] = "#{Gem.user_dir}/bin:#{ENV["PATH"]}"
diff --git a/Library/brew.rb b/Library/brew.rb
index 916e2705c..5b2af88a9 100755
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -15,10 +15,10 @@ $:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
require "global"
if ARGV.first == "--version"
- puts HOMEBREW_VERSION
+ puts Homebrew.homebrew_version_string
exit 0
elsif ARGV.first == "-v"
- puts "Homebrew #{HOMEBREW_VERSION}"
+ puts "Homebrew #{Homebrew.homebrew_version_string}"
# Shift the -v to the end of the parameter list
ARGV << ARGV.shift
# If no other arguments, just quit here.