aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-09-14 15:19:05 +0800
committerXu Cheng2015-09-14 21:07:37 +0800
commit6792847fc1534b6471ed08e82bac66a01fe1c113 (patch)
tree9e27ed5fb0f27e8131a26e3bcbd8e7ef8c2453d3 /Library
parent71198041c66e7544d31f80f3724691fa88179671 (diff)
downloadbrew-6792847fc1534b6471ed08e82bac66a01fe1c113.tar.bz2
fix update-test
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>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/dev-cmd/update-test.rb23
1 files changed, 15 insertions, 8 deletions
diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb
index 7263c9ca9..2285dafd0 100644
--- a/Library/Homebrew/dev-cmd/update-test.rb
+++ b/Library/Homebrew/dev-cmd/update-test.rb
@@ -2,26 +2,33 @@ require "extend/ENV"
module Homebrew
def update_test
- homebrew_repository_git = HOMEBREW_REPOSITORY/".git"
-
mktemp do
curdir = Pathname.new(Dir.pwd)
- ohai "Setup test environment..."
+ oh1 "Setup test environment..."
# copy Homebrew installation
- cp_r homebrew_repository_git, curdir/".git"
+ 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", "origin/master"
+ safe_system "git", "reset", "--hard", end_sha1
+ safe_system "git", "push", "--force", "origin", "master"
- # set git origin
- safe_system "git", "config", "remote.origin.url", "file://#{homebrew_repository_git}"
+ # 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
- ohai "Running brew update..."
+ oh1 "Running brew update..."
safe_system "brew", "update", "--verbose"
end
end