livecheck: changes made and improved test
This commit is contained in:
parent
4e0cc48b65
commit
2550af57df
@ -102,8 +102,9 @@ module Homebrew
|
||||
latest = Version.new(m[1])
|
||||
end
|
||||
|
||||
# A HEAD-only formula is outdated when the latest commit hash and installed commit hash differ
|
||||
is_outdated = if formula.head?
|
||||
# A HEAD-only formula is considered outdated if the latest upstream
|
||||
# commit hash is different than the installed version's commit hash
|
||||
(current != latest)
|
||||
else
|
||||
(current < latest)
|
||||
@ -148,7 +149,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
if [args.newer_only?, !has_a_newer_upstream_version, !args.json?, !args.debug?].all?
|
||||
if args.newer_only? && !has_a_newer_upstream_version && !args.debug? && !args.json?
|
||||
puts "No newer upstream versions."
|
||||
end
|
||||
|
||||
@ -167,7 +168,7 @@ module Homebrew
|
||||
formula: formula_name(formula, args: args),
|
||||
status: status_str,
|
||||
}
|
||||
status_hash[:messages] = messages.presence
|
||||
status_hash[:messages] = messages if messages.is_a?(Array)
|
||||
|
||||
if args.verbose?
|
||||
status_hash[:meta] = {
|
||||
@ -273,7 +274,7 @@ module Homebrew
|
||||
# @return [String]
|
||||
def preprocess_url(url)
|
||||
# Check for GitHub repos on github.com, not AWS
|
||||
url.sub!("github.s3.amazonaws.com", "github.com") if url.include?("github")
|
||||
url = url.sub("github.s3.amazonaws.com", "github.com") if url.include?("github")
|
||||
|
||||
# Use repo from GitHub or GitLab inferred from download URL
|
||||
if url.include?("github.com") && GITHUB_SPECIAL_CASES.none? { |sc| url.include? sc }
|
||||
|
||||
@ -13,7 +13,7 @@ describe Homebrew::Livecheck do
|
||||
head "https://github.com/Homebrew/brew.git"
|
||||
|
||||
livecheck do
|
||||
url(+"https://github.s3.amazonaws.com/Homebrew/brew/releases/latest")
|
||||
url "https://github.s3.amazonaws.com/Homebrew/brew/releases/latest"
|
||||
regex(%r{href=.*?/tag/v?(\d+(?:\.\d+)+)["' >]}i)
|
||||
end
|
||||
end
|
||||
@ -80,11 +80,11 @@ describe Homebrew::Livecheck do
|
||||
|
||||
describe "::status_hash" do
|
||||
it "returns a hash containing the livecheck status" do
|
||||
expect(livecheck.status_hash(f, "blah", ["blah"], args: args))
|
||||
expect(livecheck.status_hash(f, "error", ["Unable to get versions"], args: args))
|
||||
.to eq({
|
||||
formula: "test",
|
||||
status: "blah",
|
||||
messages: ["blah"],
|
||||
status: "error",
|
||||
messages: ["Unable to get versions"],
|
||||
meta: {
|
||||
livecheckable: true,
|
||||
},
|
||||
@ -146,11 +146,12 @@ describe Homebrew::Livecheck do
|
||||
|
||||
describe "::livecheck_formulae", :needs_network do
|
||||
it "checks for the latest versions of the formulae" do
|
||||
allow(args).to receive(:debug?).and_return(false)
|
||||
allow(args).to receive(:debug?).and_return(true)
|
||||
allow(args).to receive(:newer_only?).and_return(false)
|
||||
|
||||
expect { livecheck.livecheck_formulae([f], args) }
|
||||
.to output(/test : 0\.0\.1 ==> (\d+(?:\.\d+)+)/im).to_stdout
|
||||
expectation = expect { livecheck.livecheck_formulae([f], args) }
|
||||
expectation.to output(/Strategy:.*PageMatch/).to_stdout
|
||||
expectation.to output(/test : 0\.0\.1 ==> (\d+(?:\.\d+)+)/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user