mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
dev-cmd/update-test: various consistency fixes.
This commit is contained in:
parent
b9a30d154f
commit
86538a444a
@ -46,19 +46,24 @@ module Homebrew
|
||||
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
|
||||
elsif args.to_tag?
|
||||
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||
previous_tag = tags.lines.second
|
||||
previous_tag ||= begin
|
||||
if (HOMEBREW_REPOSITORY/".git/shallow").exist?
|
||||
if tags.blank?
|
||||
tags = if (HOMEBREW_REPOSITORY/".git/shallow").exist?
|
||||
safe_system "git", "fetch", "--tags", "--depth=1"
|
||||
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||
Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||
elsif OS.linux?
|
||||
tags = Utils.popen_read("git tag --list | sort -rV")
|
||||
Utils.popen_read("git tag --list | sort -rV")
|
||||
end
|
||||
tags.lines.second
|
||||
end
|
||||
current_tag, previous_tag, = tags.lines
|
||||
current_tag = current_tag.to_s.chomp
|
||||
odie "Could not find current tag in:\n#{tags}" if current_tag.empty?
|
||||
# ^0 ensures this points to the commit rather than the tag object.
|
||||
end_commit = "#{current_tag}^0"
|
||||
|
||||
previous_tag = previous_tag.to_s.chomp
|
||||
odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty?
|
||||
previous_tag
|
||||
# ^0 ensures this points to the commit rather than the tag object.
|
||||
"#{previous_tag}^0"
|
||||
else
|
||||
Utils.popen_read("git", "rev-parse", "origin/master").chomp
|
||||
end
|
||||
@ -67,8 +72,13 @@ module Homebrew
|
||||
start_commit = Utils.popen_read("git", "rev-parse", start_commit).chomp
|
||||
odie "Could not find start commit!" if start_commit.empty?
|
||||
|
||||
end_commit = Utils.popen_read("git", "rev-parse", "HEAD").chomp
|
||||
end_commit ||= "HEAD"
|
||||
end_commit = Utils.popen_read("git", "rev-parse", end_commit).chomp
|
||||
odie "Could not find end commit!" if end_commit.empty?
|
||||
|
||||
if Utils.popen_read("git", "branch", "--list", "master").blank?
|
||||
safe_system "git", "branch", "master", "origin/master"
|
||||
end
|
||||
end
|
||||
|
||||
puts "Start commit: #{start_commit}"
|
||||
@ -80,10 +90,12 @@ module Homebrew
|
||||
|
||||
oh1 "Setup test environment..."
|
||||
# copy Homebrew installation
|
||||
safe_system "git", "clone", "--local", "#{HOMEBREW_REPOSITORY}/.git", "."
|
||||
safe_system "git", "clone", "#{HOMEBREW_REPOSITORY}/.git", ".",
|
||||
"--local", "--branch", "master", "--single-branch"
|
||||
|
||||
# set git origin to another copy
|
||||
safe_system "git", "clone", "--local", "--bare", "#{HOMEBREW_REPOSITORY}/.git", "remote.git"
|
||||
safe_system "git", "clone", "#{HOMEBREW_REPOSITORY}/.git", "remote.git",
|
||||
"--local", "--bare", "--branch", "master", "--single-branch"
|
||||
safe_system "git", "config", "remote.origin.url", "#{curdir}/remote.git"
|
||||
|
||||
# force push origin to end_commit
|
||||
@ -100,7 +112,7 @@ module Homebrew
|
||||
oh1 "Running brew update..."
|
||||
safe_system "brew", "update", "--verbose"
|
||||
actual_end_commit = Utils.popen_read("git", "rev-parse", branch).chomp
|
||||
if start_commit != end_commit && start_commit == actual_end_commit
|
||||
if actual_end_commit != end_commit
|
||||
raise <<~EOS
|
||||
brew update didn't update #{branch}!
|
||||
Start commit: #{start_commit}
|
||||
@ -110,6 +122,6 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
ensure
|
||||
FileUtils.rm_r "update-test" unless args.keep_tmp?
|
||||
FileUtils.rm_rf "update-test" unless args.keep_tmp?
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user