Module: Homebrew::Livecheck Private

Extended by:
T::Sig
Defined in:
brew/Library/Homebrew/livecheck/livecheck.rb,
brew/Library/Homebrew/livecheck/error.rb,
brew/Library/Homebrew/livecheck/strategy.rb,
brew/Library/Homebrew/livecheck/strategy/git.rb,
brew/Library/Homebrew/livecheck/strategy/gnu.rb,
brew/Library/Homebrew/livecheck/strategy/npm.rb,
brew/Library/Homebrew/livecheck/strategy/cpan.rb,
brew/Library/Homebrew/livecheck/strategy/pypi.rb,
brew/Library/Homebrew/livecheck/strategy/xorg.rb,
brew/Library/Homebrew/livecheck/strategy/gnome.rb,
brew/Library/Homebrew/livecheck/skip_conditions.rb,
brew/Library/Homebrew/livecheck/strategy/apache.rb,
brew/Library/Homebrew/livecheck/strategy/hackage.rb,
brew/Library/Homebrew/livecheck/strategy/sparkle.rb,
brew/Library/Homebrew/livecheck/strategy/bitbucket.rb,
brew/Library/Homebrew/livecheck/strategy/launchpad.rb,
brew/Library/Homebrew/livecheck/strategy/page_match.rb,
brew/Library/Homebrew/livecheck/strategy/sourceforge.rb,
brew/Library/Homebrew/livecheck/strategy/header_match.rb,
brew/Library/Homebrew/livecheck/strategy/github_latest.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

The Livecheck module consists of methods used by the brew livecheck command. These methods print the requested livecheck information for formulae.

Defined Under Namespace

Modules: SkipConditions, Strategy Classes: Error

Constant Summary collapse

GITEA_INSTANCES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%w[
  codeberg.org
  gitea.com
  opendev.org
  tildegit.org
].freeze
GOGS_INSTANCES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%w[
  lolg.it
].freeze
STRATEGY_SYMBOLS_TO_SKIP_PREPROCESS_URL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[
  :github_latest,
  :page_match,
  :header_match,
  :sparkle,
].freeze
UNSTABLE_VERSION_KEYWORDS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%w[
  alpha
  beta
  bpo
  dev
  experimental
  prerelease
  preview
  rc
].freeze

Class Method Summary collapse

Class Method Details

.actual_version(formula_or_cask, version) ⇒ Version

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:



575
576
577
578
579
580
581
582
583
584
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 575

def actual_version(formula_or_cask, version)
  case formula_or_cask
  when Formula
    version
  when Cask::Cask
    Version.new(Cask::DSL::Version.new(version.to_s).before_comma)
  else
    T.absurd(formula_or_cask)
  end
end

.cask_name(cask, full_name: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the fully-qualified name of a cask if the full_name argument is provided; returns the name otherwise.

Parameters:

  • cask (Cask::Cask)
  • full_name (Boolean) (defaults to: false)

Returns:



260
261
262
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 260

def cask_name(cask, full_name: false)
  full_name ? cask.full_name : cask.token
end

.checkable_urls(formula_or_cask) ⇒ Array<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns an Array containing the formula/cask URLs that can be used by livecheck.

Parameters:

Returns:



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 343

def checkable_urls(formula_or_cask)
  urls = []

  case formula_or_cask
  when Formula
    urls << formula_or_cask.head.url if formula_or_cask.head
    if formula_or_cask.stable
      urls << formula_or_cask.stable.url
      urls.concat(formula_or_cask.stable.mirrors)
    end
    urls << formula_or_cask.homepage if formula_or_cask.homepage
  when Cask::Cask
    urls << formula_or_cask.appcast.to_s if formula_or_cask.appcast
    urls << formula_or_cask.url.to_s if formula_or_cask.url
    urls << formula_or_cask.homepage if formula_or_cask.homepage
  else
    T.absurd(formula_or_cask)
  end

  urls.compact
end

.formula_name(formula, full_name: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the fully-qualified name of a formula if the full_name argument is provided; returns the name otherwise.

Parameters:

  • formula (Formula)
  • full_name (Boolean) (defaults to: false)

Returns:



267
268
269
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 267

def formula_name(formula, full_name: false)
  full_name ? formula.full_name : formula.name
end

.formula_or_cask_name(formula_or_cask, full_name: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:



246
247
248
249
250
251
252
253
254
255
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 246

def formula_or_cask_name(formula_or_cask, full_name: false)
  case formula_or_cask
  when Formula
    formula_name(formula_or_cask, full_name: full_name)
  when Cask::Cask
    cask_name(formula_or_cask, full_name: full_name)
  else
    T.absurd(formula_or_cask)
  end
end

.latest_version(formula_or_cask, json: false, full_name: false, verbose: false, debug: false) ⇒ Hash?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Identifies the latest version of the formula and returns a Hash containing the version information. Returns nil if a latest version couldn’t be found.

Parameters:

  • formula_or_cask (Formula, Cask::Cask)
  • json (Boolean) (defaults to: false)
  • full_name (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • debug (Boolean) (defaults to: false)

Returns:

  • (Hash, nil)


418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 418

def latest_version(formula_or_cask, json: false, full_name: false, verbose: false, debug: false)
  formula = formula_or_cask if formula_or_cask.is_a?(Formula)
  cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)

  has_livecheckable = formula_or_cask.livecheckable?
  livecheck = formula_or_cask.livecheck
  livecheck_url = livecheck.url
  livecheck_regex = livecheck.regex
  livecheck_strategy = livecheck.strategy

  livecheck_url_string = livecheck_url_to_string(livecheck_url, formula_or_cask)

  urls = [livecheck_url_string] if livecheck_url_string
  urls ||= checkable_urls(formula_or_cask)

  if debug
    puts
    if formula
      puts "Formula:          #{formula_name(formula, full_name: full_name)}"
      puts "Head only?:       true" if formula.head_only?
    elsif cask
      puts "Cask:             #{cask_name(formula_or_cask, full_name: full_name)}"
    end
    puts "Livecheckable?:   #{has_livecheckable ? "Yes" : "No"}"
  end

  urls.each_with_index do |original_url, i|
    if debug
      puts
      if livecheck_url.is_a?(Symbol)
        # This assumes the URL symbol will fit within the available space
        puts "URL (#{livecheck_url}):".ljust(18, " ") + original_url
      else
        puts "URL:              #{original_url}"
      end
    end

    # Skip Gists until/unless we create a method of identifying revisions
    if original_url.include?("gist.github.com")
      odebug "Skipping: GitHub Gists are not supported"
      next
    end

    # Only preprocess the URL when it's appropriate
    url = if STRATEGY_SYMBOLS_TO_SKIP_PREPROCESS_URL.include?(livecheck_strategy)
      original_url
    else
      preprocess_url(original_url)
    end

    strategies = Strategy.from_url(
      url,
      livecheck_strategy: livecheck_strategy,
      url_provided:       livecheck_url.present?,
      regex_provided:     livecheck_regex.present?,
      block_provided:     livecheck.strategy_block.present?,
    )
    strategy = Strategy.from_symbol(livecheck_strategy)
    strategy ||= strategies.first
    strategy_name = livecheck_strategy_names[strategy]

    if debug
      puts "URL (processed):  #{url}" if url != original_url
      if strategies.present? && verbose
        puts "Strategies:       #{strategies.map { |s| livecheck_strategy_names[s] }.join(", ")}"
      end
      puts "Strategy:         #{strategy.blank? ? "None" : strategy_name}"
      puts "Regex:            #{livecheck_regex.inspect}" if livecheck_regex.present?
    end

    if livecheck_strategy == :page_match && (livecheck_regex.blank? && livecheck.strategy_block.blank?)
      odebug "#{strategy_name} strategy requires a regex or block"
      next
    end

    if livecheck_strategy.present? && livecheck_url.blank?
      odebug "#{strategy_name} strategy requires a url"
      next
    end

    if livecheck_strategy.present? && strategies.exclude?(strategy)
      odebug "#{strategy_name} strategy does not apply to this URL"
      next
    end

    next if strategy.blank?

    strategy_data = strategy.find_versions(url, livecheck_regex, &livecheck.strategy_block)
    match_version_map = strategy_data[:matches]
    regex = strategy_data[:regex]
    messages = strategy_data[:messages]

    if messages.is_a?(Array) && match_version_map.blank?
      puts messages unless json
      next if i + 1 < urls.length

      return status_hash(formula_or_cask, "error", messages, full_name: full_name, verbose: verbose)
    end

    if debug
      puts "URL (strategy):   #{strategy_data[:url]}" if strategy_data[:url] != url
      puts "URL (final):      #{strategy_data[:final_url]}" if strategy_data[:final_url]
      puts "Regex (strategy): #{strategy_data[:regex].inspect}" if strategy_data[:regex] != livecheck_regex
      puts "Cached?:          Yes" if strategy_data[:cached] == true
    end

    match_version_map.delete_if do |_match, version|
      next true if version.blank?
      next false if has_livecheckable

      UNSTABLE_VERSION_KEYWORDS.any? do |rejection|
        version.to_s.include?(rejection)
      end
    end

    if debug && match_version_map.present?
      puts
      puts "Matched Versions:"

      if verbose
        match_version_map.each do |match, version|
          puts "#{match} => #{version.inspect}"
        end
      else
        puts match_version_map.values.join(", ")
      end
    end

    next if match_version_map.blank?

    version_info = {
      latest: Version.new(match_version_map.values.max_by { |v| actual_version(formula_or_cask, v) }),
    }

    if json && verbose
      version_info[:meta] = {}

      version_info[:meta][:url] = {}
      version_info[:meta][:url][:symbol] = livecheck_url if livecheck_url.is_a?(Symbol) && livecheck_url_string
      version_info[:meta][:url][:original] = original_url
      version_info[:meta][:url][:processed] = url if url != original_url
      version_info[:meta][:url][:strategy] = strategy_data[:url] if strategy_data[:url] != url
      version_info[:meta][:url][:final] = strategy_data[:final_url] if strategy_data[:final_url]

      version_info[:meta][:strategy] = strategy.present? ? strategy_name : nil
      version_info[:meta][:strategies] = strategies.map { |s| livecheck_strategy_names[s] } if strategies.present?
      version_info[:meta][:regex] = regex.inspect if regex.present?
      version_info[:meta][:cached] = true if strategy_data[:cached] == true
    end

    return version_info
  end

  nil
end

.livecheck_strategy_namesHash{Class => String}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



51
52
53
54
55
56
57
58
59
60
61
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 51

def livecheck_strategy_names
  return @livecheck_strategy_names if defined?(@livecheck_strategy_names)

  # Cache demodulized strategy names, to avoid repeating this work
  @livecheck_strategy_names = {}
  Strategy.constants.sort.each do |strategy_symbol|
    strategy = Strategy.const_get(strategy_symbol)
    @livecheck_strategy_names[strategy] = strategy.name.demodulize
  end
  @livecheck_strategy_names.freeze
end

.livecheck_url_to_string(livecheck_url, formula_or_cask) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:



328
329
330
331
332
333
334
335
336
337
338
339
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 328

def livecheck_url_to_string(livecheck_url, formula_or_cask)
  case livecheck_url
  when String
    livecheck_url
  when :url
    formula_or_cask.url&.to_s if formula_or_cask.is_a?(Cask::Cask)
  when :head, :stable
    formula_or_cask.send(livecheck_url)&.url if formula_or_cask.is_a?(Formula)
  when :homepage
    formula_or_cask.homepage
  end
end

.preprocess_url(url) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Preprocesses and returns the URL used by livecheck.

Parameters:

Returns:



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 367

def preprocess_url(url)
  begin
    uri = URI.parse url
  rescue URI::InvalidURIError
    return url
  end

  host = uri.host
  path = uri.path
  return url if host.nil? || path.nil?

  host = "github.com" if host == "github.s3.amazonaws.com"
  path = path.delete_prefix("/").delete_suffix(".git")
  scheme = uri.scheme

  if host.end_with?("github.com")
    return url if path.match? %r{/releases/latest/?$}

    owner, repo = path.delete_prefix("downloads/").split("/")
    url = "#{scheme}://#{host}/#{owner}/#{repo}.git"
  elsif host.end_with?(*GITEA_INSTANCES)
    return url if path.match? %r{/releases/latest/?$}

    owner, repo = path.split("/")
    url = "#{scheme}://#{host}/#{owner}/#{repo}.git"
  elsif host.end_with?(*GOGS_INSTANCES)
    owner, repo = path.split("/")
    url = "#{scheme}://#{host}/#{owner}/#{repo}.git"
  # sourcehut
  elsif host.end_with?("git.sr.ht")
    owner, repo = path.split("/")
    url = "#{scheme}://#{host}/#{owner}/#{repo}"
  # GitLab (gitlab.com or self-hosted)
  elsif path.include?("/-/archive/")
    url = url.sub(%r{/-/archive/.*$}i, ".git")
  end

  url
end

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Formats and prints the livecheck result for a formula.

Parameters:

  • info (Hash)
  • verbose (Boolean)


303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 303

def print_latest_version(info, verbose:)
  formula_or_cask_s = "#{Tty.blue}#{info[:formula] || info[:cask]}#{Tty.reset}"
  formula_or_cask_s += " (guessed)" if !info[:meta][:livecheckable] && verbose

  current_s = if info[:version][:newer_than_upstream]
    "#{Tty.red}#{info[:version][:current]}#{Tty.reset}"
  else
    info[:version][:current]
  end

  latest_s = if info[:version][:outdated]
    "#{Tty.green}#{info[:version][:latest]}#{Tty.reset}"
  else
    info[:version][:latest]
  end

  puts "#{formula_or_cask_s} : #{current_s} ==> #{latest_s}"
end

.run_checks(formulae_and_casks_to_check, full_name: false, json: false, newer_only: false, debug: false, quiet: false, verbose: false) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Executes the livecheck logic for each formula/cask in the formulae_and_casks_to_check array and prints the results.

Parameters:

  • formulae_and_casks_to_check (Enumerable<Formula, Cask::Cask>)
  • full_name (Boolean) (defaults to: false)
  • json (Boolean) (defaults to: false)
  • newer_only (Boolean) (defaults to: false)
  • debug (Boolean) (defaults to: false)
  • quiet (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 76

def run_checks(
  formulae_and_casks_to_check,
  full_name: false, json: false, newer_only: false, debug: false, quiet: false, verbose: false
)
  # Identify any non-homebrew/core taps in use for current formulae
  non_core_taps = {}
  formulae_and_casks_to_check.each do |formula_or_cask|
    next if formula_or_cask.tap.blank?
    next if formula_or_cask.tap.name == CoreTap.instance.name
    next if non_core_taps[formula_or_cask.tap.name]

    non_core_taps[formula_or_cask.tap.name] = formula_or_cask.tap
  end
  non_core_taps = non_core_taps.sort.to_h

  # Load additional Strategy files from taps
  non_core_taps.each_value do |tap|
    tap_strategy_path = "#{tap.path}/livecheck/strategy"
    Dir["#{tap_strategy_path}/*.rb"].sort.each(&method(:require)) if Dir.exist?(tap_strategy_path)
  end

  has_a_newer_upstream_version = T.let(false, T::Boolean)

  if json && !quiet && $stderr.tty?
    formulae_and_casks_total = formulae_and_casks_to_check.count

    Tty.with($stderr) do |stderr|
      stderr.puts Formatter.headline("Running checks", color: :blue)
    end

    progress = ProgressBar.create(
      total:          formulae_and_casks_total,
      progress_mark:  "#",
      remainder_mark: ".",
      format:         " %t: [%B] %c/%C ",
      output:         $stderr,
    )
  end

  formulae_checked = formulae_and_casks_to_check.map.with_index do |formula_or_cask, i|
    formula = formula_or_cask if formula_or_cask.is_a?(Formula)
    cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)
    name = formula_or_cask_name(formula_or_cask, full_name: full_name)

    if debug && i.positive?
      puts <<~EOS

        ----------

      EOS
    end

    skip_info = SkipConditions.skip_information(formula_or_cask, full_name: full_name, verbose: verbose)
    if skip_info.present?
      next skip_info if json

      SkipConditions.print_skip_information(skip_info) unless quiet
      next
    end

    formula&.head&.downloader&.shutup!

    # Use the `stable` version for comparison except for installed
    # head-only formulae. A formula with `stable` and `head` that's
    # installed using `--head` will still use the `stable` version for
    # comparison.
    current = if formula
      if formula.head_only?
        formula.any_installed_version.version.commit
      else
        formula.stable.version
      end
    else
      Version.new(formula_or_cask.version)
    end

    current_str = current.to_s
    current = actual_version(formula_or_cask, current)

    latest = if formula&.head_only?
      formula.head.downloader.fetch_last_commit
    else
      version_info = latest_version(
        formula_or_cask,
        json: json, full_name: full_name, verbose: verbose, debug: debug,
      )
      version_info[:latest] if version_info.present?
    end

    if latest.blank?
      no_versions_msg = "Unable to get versions"
      raise Livecheck::Error, no_versions_msg unless json

      next version_info if version_info.is_a?(Hash) && version_info[:status] && version_info[:messages]

      next status_hash(formula_or_cask, "error", [no_versions_msg], full_name: full_name, verbose: verbose)
    end

    if (m = latest.to_s.match(/(.*)-release$/)) && !current.to_s.match(/.*-release$/)
      latest = Version.new(m[1])
    end

    latest_str = latest.to_s
    latest = actual_version(formula_or_cask, latest)

    is_outdated = if formula&.head_only?
      # 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)
    end

    is_newer_than_upstream = (formula&.stable? || cask) && (current > latest)

    info = {}
    info[:formula] = name if formula
    info[:cask] = name if cask
    info[:version] = {
      current:             current_str,
      latest:              latest_str,
      outdated:            is_outdated,
      newer_than_upstream: is_newer_than_upstream,
    }
    info[:meta] = {
      livecheckable: formula_or_cask.livecheckable?,
    }
    info[:meta][:head_only] = true if formula&.head_only?
    info[:meta].merge!(version_info[:meta]) if version_info.present? && version_info.key?(:meta)

    next if newer_only && !info[:version][:outdated]

    has_a_newer_upstream_version ||= true

    if json
      progress&.increment
      info.except!(:meta) unless verbose
      next info
    end

    print_latest_version(info, verbose: verbose)
    nil
  rescue => e
    Homebrew.failed = true

    if json
      progress&.increment
      status_hash(formula_or_cask, "error", [e.to_s], full_name: full_name, verbose: verbose)
    elsif !quiet
      onoe "#{Tty.blue}#{name}#{Tty.reset}: #{e}"
      $stderr.puts e.backtrace if debug && !e.is_a?(Livecheck::Error)
      nil
    end
  end

  puts "No newer upstream versions." if newer_only && !has_a_newer_upstream_version && !debug && !json

  return unless json

  if progress
    progress.finish
    Tty.with($stderr) do |stderr|
      stderr.print "#{Tty.up}#{Tty.erase_line}" * 2
    end
  end

  puts JSON.generate(formulae_checked.compact)
end

.status_hash(formula_or_cask, status_str, messages = nil, full_name: false, verbose: false) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • formula_or_cask (Formula, Cask::Cask)
  • status_str (String)
  • messages (Array<String>, nil) (defaults to: nil)
  • full_name (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)

Returns:

  • (Hash)


280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'brew/Library/Homebrew/livecheck/livecheck.rb', line 280

def status_hash(formula_or_cask, status_str, messages = nil, full_name: false, verbose: false)
  formula = formula_or_cask if formula_or_cask.is_a?(Formula)
  cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)

  status_hash = {}
  if formula
    status_hash[:formula] = formula_name(formula, full_name: full_name)
  elsif cask
    status_hash[:cask] = cask_name(formula_or_cask, full_name: full_name)
  end
  status_hash[:status] = status_str
  status_hash[:messages] = messages if messages.is_a?(Array)

  status_hash[:meta] = {
    livecheckable: formula_or_cask.livecheckable?,
  }
  status_hash[:meta][:head_only] = true if formula&.head_only?

  status_hash
end