forked from Homebrew/brew
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sam Ford <[email protected]> Co-authored-by: Thierry Moisan <[email protected]> Co-authored-by: Dawid Dziurla <[email protected]> Co-authored-by: Maxim Belkin <[email protected]> Co-authored-by: Issy Long <[email protected]> Co-authored-by: Mike McQuaid <[email protected]> Co-authored-by: Seeker <[email protected]>
- Loading branch information
1 parent
44c826e
commit e5fe57c
Showing
11 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# frozen_string_literal: true | ||
|
||
require "cli/parser" | ||
require "formula" | ||
require "livecheck/livecheck" | ||
require "livecheck/strategy" | ||
|
||
module Homebrew | ||
module_function | ||
|
||
WATCHLIST_PATH = ( | ||
ENV["HOMEBREW_LIVECHECK_WATCHLIST"] || | ||
Pathname.new(Dir.home)/".brew_livecheck_watchlist" | ||
).freeze | ||
|
||
def livecheck_args | ||
Homebrew::CLI::Parser.new do | ||
usage_banner <<~EOS | ||
`livecheck` [<formulae>] | ||
Check for newer versions of formulae from upstream. | ||
If no formula argument is passed, the list of formulae to check is taken from `HOMEBREW_LIVECHECK_WATCHLIST` | ||
or `~/.brew_livecheck_watchlist`. | ||
EOS | ||
switch "--full-name", | ||
description: "Print formulae with fully-qualified names." | ||
flag "--tap=", | ||
description: "Check the formulae within the given tap, specified as <user>`/`<repo>." | ||
switch "--installed", | ||
description: "Check formulae that are currently installed." | ||
switch "--json", | ||
description: "Output informations in JSON format." | ||
switch "--all", | ||
description: "Check all available formulae." | ||
switch "--newer-only", | ||
description: "Show the latest version only if it's newer than the formula." | ||
conflicts "--debug", "--json" | ||
conflicts "--tap=", "--all", "--installed" | ||
end | ||
end | ||
|
||
def livecheck | ||
args = livecheck_args.parse | ||
|
||
if args.debug? && args.verbose? | ||
puts args | ||
puts ENV["HOMEBREW_LIVECHECK_WATCHLIST"] if ENV["HOMEBREW_LIVECHECK_WATCHLIST"].present? | ||
end | ||
|
||
formulae_to_check = if args.tap | ||
Tap.fetch(args.tap).formula_names.map { |name| Formula[name] } | ||
elsif args.installed? | ||
Formula.installed | ||
elsif args.all? | ||
Formula | ||
elsif args.formulae.present? | ||
args.formulae | ||
elsif File.exist?(WATCHLIST_PATH) | ||
begin | ||
WATCHLIST_PATH.read.lines.map do |line| | ||
next if line.start_with?("#") | ||
|
||
Formula[line.strip] | ||
end.compact | ||
rescue Errno::ENOENT => e | ||
onoe e | ||
end | ||
end | ||
|
||
raise UsageError, "No formulae to check." if formulae_to_check.blank? | ||
|
||
Livecheck.livecheck_formulae(formulae_to_check, args) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
games | ||
gui | ||
head-only | ||
livecheck | ||
nginx | ||
php | ||
python | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require "cmd/shared_examples/args_parse" | ||
|
||
describe "Homebrew.livecheck_args" do | ||
it_behaves_like "parseable arguments" | ||
end | ||
|
||
describe "brew livecheck", :integration_test do | ||
it "reports the latest version of a Formula", :needs_network do | ||
content = <<~RUBY | ||
desc "Some test" | ||
homepage "https://github.com/Homebrew/brew" | ||
url "https://brew.sh/test-1.0.0.tgz" | ||
RUBY | ||
setup_test_formula("test", content) | ||
|
||
expect { brew "livecheck", "test" } | ||
.to output(/test : /).to_stdout | ||
.and not_to_output.to_stderr | ||
.and be_a_success | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ leaves | |
link | ||
linkage | ||
list | ||
livecheck | ||
ln | ||
log | ||
ls | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters