mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

Previously, `brew update-test` is run against master branch of local repo. However, we test PR using a detached branch in `brew test-bot`. The result is `brew update-test` will always be up-to-date in `test-bot`. To fix it, we create two local copies of git repo, and set master branch to start and end sha1 correspondingly. After that, `brew update` will be run to simulate the change between start and end sha1. Closes Homebrew/homebrew#43902. Signed-off-by: Xu Cheng <xucheng@me.com>
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
require "extend/ENV"
|
|
|
|
module Homebrew
|
|
def update_test
|
|
mktemp do
|
|
curdir = Pathname.new(Dir.pwd)
|
|
|
|
oh1 "Setup test environment..."
|
|
# copy Homebrew installation
|
|
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
|
|
safe_system "git", "checkout", "--force", "master"
|
|
safe_system "git", "reset", "--hard", end_sha1
|
|
safe_system "git", "push", "--force", "origin", "master"
|
|
|
|
# set test copy to start_sha1
|
|
safe_system "git", "reset", "--hard", start_sha1
|
|
|
|
# update ENV["PATH"]
|
|
ENV.extend(Stdenv)
|
|
ENV.prepend_path "PATH", "#{curdir}/bin"
|
|
|
|
# run brew update
|
|
oh1 "Running brew update..."
|
|
safe_system "brew", "update", "--verbose"
|
|
end
|
|
end
|
|
end
|