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