Class: Homebrew::DevCmd::BumpUnversionedCasks Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::BumpUnversionedCasks
- Includes:
- SystemCommand::Mixin
- Defined in:
- dev-cmd/bump-unversioned-casks.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/bump_unversioned_casks.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::BumpUnversionedCasks::Args private
- #run ⇒ void private
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::BumpUnversionedCasks::Args
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/bump_unversioned_casks.rbi', line 10 def args; end |
#run ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'dev-cmd/bump-unversioned-casks.rb', line 32 def run Homebrew.install_bundler_gems!(groups: ["bump_unversioned_casks"]) state_file = if args.state_file.present? Pathname(T.must(args.state_file)). else HOMEBREW_CACHE/"bump_unversioned_casks.json" end state_file.dirname.mkpath state = state_file.exist? ? JSON.parse(state_file.read) : {} casks = args.named.to_paths(only: :cask, recurse_tap: true).map { |path| Cask::CaskLoader.load(path) } unversioned_casks = casks.select do |cask| cask.url&.unversioned? && !cask.livecheck_defined? end ohai "Unversioned Casks: #{unversioned_casks.count} (#{state.size} cached)" checked, unchecked = unversioned_casks.partition { |c| state.key?(c.full_name) } queue = Queue.new # Start with random casks which have not been checked. unchecked.shuffle.each do |c| queue.enq c end # Continue with previously checked casks, ordered by when they were last checked. checked.sort_by { |c| state.dig(c.full_name, "check_time") }.each do |c| queue.enq c end limit = args.limit.presence&.to_i end_time = Time.now + (limit * 60) if limit until queue.empty? || (end_time && end_time < Time.now) cask = queue.deq key = cask.full_name new_state = bump_unversioned_cask(cask, state: state.fetch(key, {})) next unless new_state state[key] = new_state state_file.atomic_write JSON.pretty_generate(state) unless args.dry_run? end end |