2015-09-06 23:08:04 +08:00
|
|
|
require "extend/ENV"
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
def update_test
|
|
|
|
mktemp do
|
|
|
|
curdir = Pathname.new(Dir.pwd)
|
|
|
|
|
2015-09-14 15:19:05 +08:00
|
|
|
oh1 "Setup test environment..."
|
2015-09-06 23:08:04 +08:00
|
|
|
# copy Homebrew installation
|
2015-09-14 15:19:05 +08:00
|
|
|
cp_r HOMEBREW_REPOSITORY/".git", curdir/".git"
|
|
|
|
start_sha1 = Utils.popen_read("git", "rev-parse", "origin/master").chomp
|
|
|
|
end_sha1 = Utils.popen_read("git", "rev-parse", "HEAD").chomp
|
|
|
|
|
|
|
|
# set git origin to another copy
|
|
|
|
cp_r HOMEBREW_REPOSITORY/".git", curdir/"remote.git"
|
|
|
|
safe_system "git", "config", "remote.origin.url", "file://#{curdir}/remote.git"
|
|
|
|
|
|
|
|
# force push origin to end_sha1
|
2015-09-06 23:08:04 +08:00
|
|
|
safe_system "git", "checkout", "--force", "master"
|
2015-09-14 15:19:05 +08:00
|
|
|
safe_system "git", "reset", "--hard", end_sha1
|
|
|
|
safe_system "git", "push", "--force", "origin", "master"
|
2015-09-06 23:08:04 +08:00
|
|
|
|
2015-09-14 15:19:05 +08:00
|
|
|
# set test copy to start_sha1
|
|
|
|
safe_system "git", "reset", "--hard", start_sha1
|
2015-09-06 23:08:04 +08:00
|
|
|
|
|
|
|
# update ENV["PATH"]
|
|
|
|
ENV.extend(Stdenv)
|
|
|
|
ENV.prepend_path "PATH", "#{curdir}/bin"
|
|
|
|
|
|
|
|
# run brew update
|
2015-09-14 15:19:05 +08:00
|
|
|
oh1 "Running brew update..."
|
2015-09-14 08:00:50 +01:00
|
|
|
safe_system "brew", "update", "--verbose"
|
2015-09-06 23:08:04 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|