diff --git a/Library/Homebrew/extend/git_repository.rb b/Library/Homebrew/extend/git_repository.rb index 2f9b8d7458..0b5a6b87f6 100644 --- a/Library/Homebrew/extend/git_repository.rb +++ b/Library/Homebrew/extend/git_repository.rb @@ -8,56 +8,36 @@ module GitRepositoryExtension def git_origin return unless git? && Utils.git_available? - cd do - Utils.popen_read("git", "config", "--get", "remote.origin.url").chuzzle - end + Utils.popen_read("git", "config", "--get", "remote.origin.url", chdir: self).chuzzle end def git_origin=(origin) return unless git? && Utils.git_available? - cd do - safe_system "git", "remote", "set-url", "origin", origin - end + safe_system "git", "remote", "set-url", "origin", origin, chdir: self end def git_head return unless git? && Utils.git_available? - cd do - Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD").chuzzle - end + Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD", chdir: self).chuzzle end def git_short_head return unless git? && Utils.git_available? - cd do - Utils.popen_read( - "git", "rev-parse", "--short=4", "--verify", "-q", "HEAD" - ).chuzzle - end + Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD", chdir: self).chuzzle end def git_last_commit return unless git? && Utils.git_available? - cd do - Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD").chuzzle - end + Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD", chdir: self).chuzzle end def git_branch return unless git? && Utils.git_available? - cd do - Utils.popen_read( - "git", "rev-parse", "--abbrev-ref", "HEAD" - ).chuzzle - end + Utils.popen_read("git", "rev-parse", "--abbrev-ref", "HEAD", chdir: self).chuzzle end def git_last_commit_date return unless git? && Utils.git_available? - cd do - Utils.popen_read( - "git", "show", "-s", "--format=%cd", "--date=short", "HEAD" - ).chuzzle - end + Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD", chdir: self).chuzzle end end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 84eb8aa8cc..fb4b764d98 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -177,12 +177,12 @@ end module Homebrew module_function - def _system(cmd, *args) + def _system(cmd, *args, **options) pid = fork do yield if block_given? args.collect!(&:to_s) begin - exec(cmd, *args) + exec(cmd, *args, **options) rescue nil end @@ -192,9 +192,9 @@ module Homebrew $CHILD_STATUS.success? end - def system(cmd, *args) + def system(cmd, *args, **options) puts "#{cmd} #{args * " "}" if ARGV.verbose? - _system(cmd, *args) + _system(cmd, *args, **options) end def install_gem!(name, version = nil) @@ -294,8 +294,8 @@ def run_as_not_developer end # Kernel.system but with exceptions -def safe_system(cmd, *args) - Homebrew.system(cmd, *args) || raise(ErrorDuringExecution.new(cmd, args)) +def safe_system(cmd, *args, **options) + Homebrew.system(cmd, *args, **options) || raise(ErrorDuringExecution.new(cmd, args)) end # prints no output