Homebrew.git_*: check git available

This commit is contained in:
Xu Cheng 2015-09-08 15:19:27 +08:00
parent aae5b4f721
commit 31ddce85e7

View File

@ -150,27 +150,32 @@ module Homebrew
end
def self.git_origin
return unless Utils.git_available?
HOMEBREW_REPOSITORY.cd { `git config --get remote.origin.url 2>/dev/null`.chuzzle }
end
def self.git_head
return unless Utils.git_available?
HOMEBREW_REPOSITORY.cd { `git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle }
end
def self.git_short_head
return unless Utils.git_available?
HOMEBREW_REPOSITORY.cd { `git rev-parse --short=4 --verify -q HEAD 2>/dev/null`.chuzzle }
end
def self.git_last_commit
return unless Utils.git_available?
HOMEBREW_REPOSITORY.cd { `git show -s --format="%cr" HEAD 2>/dev/null`.chuzzle }
end
def self.git_last_commit_date
return unless Utils.git_available?
HOMEBREW_REPOSITORY.cd { `git show -s --format="%cd" --date=short HEAD 2>/dev/null`.chuzzle }
end
def self.homebrew_version_string
if Utils.git_available? && (pretty_revision = git_short_head)
if pretty_revision = git_short_head
last_commit = git_last_commit_date
"#{HOMEBREW_VERSION} (git revision #{pretty_revision}; last commit #{last_commit})"
else