Skip to content

Commit 4343324

Browse files
authored
Merge pull request #20623 from Homebrew/livecheck/support-trailing-comments-in-watchlist
livecheck: support trailing comments in watchlist
2 parents 6c98d2b + 31cf8b4 commit 4343324

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Library/Homebrew/dev-cmd/livecheck.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ def run
7878
formulae + casks
7979
elsif File.exist?(watchlist_path)
8080
begin
81+
# This removes blank lines, comment lines, and trailing comments
8182
names = Pathname.new(watchlist_path).read.lines
82-
.reject { |line| line.start_with?("#") || line.blank? }
83-
.map(&:strip)
83+
.filter_map do |line|
84+
comment_index = line.index("#")
85+
next if comment_index&.zero?
86+
87+
line = line[0...comment_index] if comment_index
88+
line&.strip.presence
89+
end
8490

8591
named_args = CLI::NamedArgs.new(*names, parent: args)
8692
named_args.to_formulae_and_casks(ignore_unavailable: true)

0 commit comments

Comments
 (0)