Use GitRepositoryExtension for HOMEBREW_REPOSITORY
This commit is contained in:
parent
6cdc6b1460
commit
77dd9d56ff
@ -805,7 +805,7 @@ module Homebrew
|
||||
def check_git_origin
|
||||
return if !Utils.git_available? || !(HOMEBREW_REPOSITORY/".git").exist?
|
||||
|
||||
origin = Homebrew.git_origin
|
||||
origin = HOMEBREW_REPOSITORY.git_origin
|
||||
|
||||
if origin.nil?
|
||||
<<-EOS.undent
|
||||
|
@ -761,7 +761,7 @@ class FormulaInstaller
|
||||
tab.tap = formula.tap
|
||||
tab.poured_from_bottle = true
|
||||
tab.time = Time.now.to_i
|
||||
tab.head = Homebrew.git_head
|
||||
tab.head = HOMEBREW_REPOSITORY.git_head
|
||||
tab.write
|
||||
end
|
||||
|
||||
|
@ -20,6 +20,8 @@ HOMEBREW_WWW = "http://brew.sh"
|
||||
|
||||
require "config"
|
||||
|
||||
HOMEBREW_REPOSITORY.extend(GitRepositoryExtension)
|
||||
|
||||
if RbConfig.respond_to?(:ruby)
|
||||
RUBY_PATH = Pathname.new(RbConfig.ruby)
|
||||
else
|
||||
|
@ -23,15 +23,15 @@ class SystemConfig
|
||||
end
|
||||
|
||||
def head
|
||||
Homebrew.git_head || "(none)"
|
||||
HOMEBREW_REPOSITORY.git_head || "(none)"
|
||||
end
|
||||
|
||||
def last_commit
|
||||
Homebrew.git_last_commit || "never"
|
||||
HOMEBREW_REPOSITORY.git_last_commit || "never"
|
||||
end
|
||||
|
||||
def origin
|
||||
Homebrew.git_origin || "(none)"
|
||||
HOMEBREW_REPOSITORY.git_origin || "(none)"
|
||||
end
|
||||
|
||||
def core_tap_head
|
||||
|
@ -24,7 +24,7 @@ class Tab < OpenStruct
|
||||
"poured_from_bottle" => false,
|
||||
"time" => Time.now.to_i,
|
||||
"source_modified_time" => source_modified_time.to_i,
|
||||
"HEAD" => Homebrew.git_head,
|
||||
"HEAD" => HOMEBREW_REPOSITORY.git_head,
|
||||
"compiler" => compiler,
|
||||
"stdlib" => stdlib,
|
||||
"source" => {
|
||||
|
@ -198,34 +198,9 @@ module Homebrew
|
||||
_system(cmd, *args)
|
||||
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 pretty_revision = git_short_head
|
||||
last_commit = git_last_commit_date
|
||||
if pretty_revision = HOMEBREW_REPOSITORY.git_short_head
|
||||
last_commit = HOMEBREW_REPOSITORY.git_last_commit_date
|
||||
"#{HOMEBREW_VERSION} (git revision #{pretty_revision}; last commit #{last_commit})"
|
||||
else
|
||||
"#{HOMEBREW_VERSION} (no git repository)"
|
||||
|
Loading…
x
Reference in New Issue
Block a user