Class: Homebrew::DevCmd::WhichUpdate Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::WhichUpdate
- Defined in:
- dev-cmd/which-update.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/which_update.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::WhichUpdate::Args private
- #run ⇒ void private
- #update_and_save!(source:, bottle_json_dir: nil, removed_formulae_file: nil, pull_request: nil, repository: nil, summary_file: nil) ⇒ Boolean private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::WhichUpdate::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/which_update.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.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'dev-cmd/which-update.rb', line 33 def run updated = update_and_save! source: args.named.fetch(0), bottle_json_dir: args.bottle_json_dir, removed_formulae_file: args.removed_formulae_file, pull_request: args.pull_request, repository: args.repository, summary_file: args.summary_file if (github_output = ENV["GITHUB_OUTPUT"].presence) File.open(github_output, "a") { |file| file.puts "updated=#{updated}" } end end |
#update_and_save!(source:, bottle_json_dir: nil, removed_formulae_file: nil, pull_request: nil, repository: nil, summary_file: nil) ⇒ Boolean
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.
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 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 |
# File 'dev-cmd/which-update.rb', line 56 def update_and_save!(source:, bottle_json_dir: nil, removed_formulae_file: nil, pull_request: nil, repository: nil, summary_file: nil) source_path = Pathname(source) original_database = source_path.exist? ? source_path.read : nil db = ExecutablesDB.new source removed_formulae = if removed_formulae_file.blank? || !File.file?(removed_formulae_file) [] else File.readlines(removed_formulae_file, chomp: true).filter_map { |line| line.strip.presence } end if pull_request repository = repository.presence || ENV["GITHUB_REPOSITORY"].presence if repository.blank? raise UsageError, "`--repository` or `$GITHUB_REPOSITORY` is required with `--pull-request`." end owner, repo = repository.split("/", 2) if owner.blank? || repo.blank? || repo.include?("/") raise UsageError, "`--repository` must be in the form `owner/repo`." end GitHub::API.paginate_rest(GitHub.url_to("repos", owner, repo, "pulls", pull_request, "files")) do |files| T.cast(files, T::Array[T::Hash[String, T.untyped]]).each do |file| filename = file["filename"].to_s next if !filename.start_with?("Formula/") || !filename.end_with?(".rb") case file["status"].to_s when "removed" removed_formulae << File.basename(filename, ".rb") when "renamed" removed_formulae << File.basename(file["previous_filename"].to_s, ".rb") end end end end db.update!(bottle_json_dir:, removed_formulae:) db.save! updated = original_database != source_path.read if summary_file File.open(summary_file, "a") do |file| file.puts <<~EOS ## Database Update Summary #{updated ? "Updated command-not-found database." : "No changes"} EOS end end updated end |