From 77dd9d56ff39f77391d2f429a9ff25e65a362ba2 Mon Sep 17 00:00:00 2001 From: Martin Afanasjew <martin@afanasjew.de> Date: Sat, 2 Jul 2016 09:44:48 +0200 Subject: [PATCH] Use GitRepositoryExtension for HOMEBREW_REPOSITORY --- Library/Homebrew/diagnostic.rb | 2 +- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/global.rb | 2 ++ Library/Homebrew/system_config.rb | 6 +++--- Library/Homebrew/tab.rb | 2 +- Library/Homebrew/utils.rb | 29 ++------------------------- 6 files changed, 10 insertions(+), 33 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 020be90536..733d368d9c 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -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 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index da626da4c4..ae594d9f7b 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -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 diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index ab6bd9d5cf..25f2d42f09 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -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 diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb index 71d5065ad3..26a0c27abd 100644 --- a/Library/Homebrew/system_config.rb +++ b/Library/Homebrew/system_config.rb @@ -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 diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index a72a3c0cce..a407496bb4 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -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" => { diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index f94477f503..61d286da54 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -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)" -- GitLab