Merge pull request #20623 from Homebrew/livecheck/support-trailing-comments-in-watchlist

livecheck: support trailing comments in watchlist
This commit is contained in:
Mike McQuaid 2025-09-03 15:35:15 +00:00 committed by GitHub
commit 4343324468
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -78,9 +78,15 @@ module Homebrew
formulae + casks formulae + casks
elsif File.exist?(watchlist_path) elsif File.exist?(watchlist_path)
begin begin
# This removes blank lines, comment lines, and trailing comments
names = Pathname.new(watchlist_path).read.lines names = Pathname.new(watchlist_path).read.lines
.reject { |line| line.start_with?("#") || line.blank? } .filter_map do |line|
.map(&:strip) comment_index = line.index("#")
next if comment_index&.zero?
line = line[0...comment_index] if comment_index
line&.strip.presence
end
named_args = CLI::NamedArgs.new(*names, parent: args) named_args = CLI::NamedArgs.new(*names, parent: args)
named_args.to_formulae_and_casks(ignore_unavailable: true) named_args.to_formulae_and_casks(ignore_unavailable: true)