Class: CoreTap Private

Inherits:
AbstractCoreTap show all
Defined in:
tap.rb

Overview

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.

A specialized Tap class for the core formulae.

Constant Summary

Constants inherited from Tap

Tap::HOMEBREW_TAP_JSON_FILES, Tap::TAP_DIRECTORY

Instance Attribute Summary

Attributes inherited from Tap

#full_name, #git_repository, #name, #path, #repository, #user

Instance Method Summary collapse

Methods inherited from AbstractCoreTap

ensure_installed!, #formula_file_to_name, instance, #should_report_analytics?

Methods inherited from Tap

#alias_files, #alias_reverse_table, #aliases, all, #allow_bump?, #allowed_by_env?, allowed_taps, #audit_exception, #cask_dir, #cask_file?, #cask_files, #cask_files_by_name, #cask_renames, #cask_reverse_renames, #cask_tokens, #clear_cache, cmd_directories, #command_dir, #command_files, #config, #contents, #core_cask_tap?, #custom_remote?, #default_remote, each, fetch, #fix_remote_configuration, #forbidden_by_env?, forbidden_taps, #formula_file?, #formula_file_to_name, #formula_reverse_renames, from_path, #git?, #git_branch, #git_head, #git_last_commit, installed, #installed?, #issues_url, #link_completions_and_manpages, names, #new_cask_path, #official?, #potential_formula_dirs, #prefix_to_versioned_formulae_names, #private?, #relative_cask_path, #remote_repo, #repository_var_suffix, #reverse_tap_migrations_renames, #shallow?, #should_report_analytics?, tap_migration_oldnames, #to_hash, untapped_official_taps, with_cask_token, with_formula_name

Methods included from Cachable

#cache, #clear_cache

Methods included from Enumerable

#compact_blank, #exclude?

Constructor Details

#initializevoid

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.



1191
1192
1193
# File 'tap.rb', line 1191

def initialize
  super "Homebrew", "core"
end

Instance Method Details

#alias_dirPathname

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.

Returns:



1264
1265
1266
1267
1268
1269
# File 'tap.rb', line 1264

def alias_dir
  @alias_dir ||= begin
    ensure_installed!
    super
  end
end

#alias_file_to_name(file) ⇒ String

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.

Parameters:

Returns:



1336
1337
1338
# File 'tap.rb', line 1336

def alias_file_to_name(file)
  file.basename.to_s
end

#alias_tableHash{String => String}

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.

Returns:



1341
1342
1343
1344
1345
1346
1347
# File 'tap.rb', line 1341

def alias_table
  @alias_table ||= if Homebrew::EnvConfig.no_install_from_api?
    super
  else
    Homebrew::API::Formula.all_aliases
  end
end

#audit_exceptionsHash

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.

Returns:



1304
1305
1306
1307
1308
1309
# File 'tap.rb', line 1304

def audit_exceptions
  @audit_exceptions ||= begin
    ensure_installed!
    super
  end
end

#autobumpArray<String>

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.

Returns:



1296
1297
1298
1299
1300
1301
# File 'tap.rb', line 1296

def autobump
  @autobump ||= begin
    ensure_installed!
    super
  end
end

#core_tap?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.

Returns:

  • (Boolean)


1233
1234
1235
# File 'tap.rb', line 1233

def core_tap?
  true
end

#ensure_installed!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.



1196
1197
1198
1199
1200
# File 'tap.rb', line 1196

def ensure_installed!
  return if ENV["HOMEBREW_TESTS"]

  super
end

#formula_dirPathname

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.

Returns:



1243
1244
1245
1246
1247
1248
# File 'tap.rb', line 1243

def formula_dir
  @formula_dir ||= begin
    ensure_installed!
    super
  end
end

#formula_filesArray<Pathname>

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.

Returns:



1350
1351
1352
1353
1354
# File 'tap.rb', line 1350

def formula_files
  return super if Homebrew::EnvConfig.no_install_from_api?

  formula_files_by_name.values
end

#formula_files_by_nameHash{String => Pathname}

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.

Returns:



1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
# File 'tap.rb', line 1364

def formula_files_by_name
  return super if Homebrew::EnvConfig.no_install_from_api?

  @formula_files_by_name ||= begin
    tap_path = path.to_s
    Homebrew::API::Formula.all_formulae.each_with_object({}) do |item, hash|
      name, formula_hash = item
      # If there's more than one item with the same path: use the longer one to prioritise more specific results.
      existing_path = hash[name]
      # Pathname equivalent is slow in a tight loop
      new_path = File.join(tap_path, formula_hash.fetch("ruby_source_path"))
      hash[name] = Pathname(new_path) if existing_path.nil? || existing_path.to_s.length < new_path.length
    end
  end
end

#formula_namesArray<String>

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.

Returns:



1357
1358
1359
1360
1361
# File 'tap.rb', line 1357

def formula_names
  return super if Homebrew::EnvConfig.no_install_from_api?

  Homebrew::API::Formula.all_formulae.keys
end

#formula_renamesHash{String => String}

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.

Returns:



1272
1273
1274
1275
1276
1277
1278
1279
# File 'tap.rb', line 1272

def formula_renames
  @formula_renames ||= if Homebrew::EnvConfig.no_install_from_api?
    ensure_installed!
    super
  else
    Homebrew::API::Formula.all_renames
  end
end

#install(quiet: false, clone_target: nil, custom_remote: false, verify: false, force: false) ⇒ Object

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.

CoreTap never allows shallow clones (on request from GitHub).



1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
# File 'tap.rb', line 1210

def install(quiet: false, clone_target: nil,
            custom_remote: false, verify: false, force: false)
  remote = Homebrew::EnvConfig.core_git_remote # set by HOMEBREW_CORE_GIT_REMOTE
  requested_remote = clone_target || remote

  # The remote will changed again on `brew update` since remotes for homebrew/core are mismatched
  raise TapCoreRemoteMismatchError.new(name, remote, requested_remote) if requested_remote != remote

  if remote != default_remote
    $stderr.puts "HOMEBREW_CORE_GIT_REMOTE set: using #{remote} as the Homebrew/homebrew-core Git remote."
  end

  super(quiet:, clone_target: remote, custom_remote:, force:)
end

#linuxbrew_core?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.

Returns:

  • (Boolean)


1238
1239
1240
# File 'tap.rb', line 1238

def linuxbrew_core?
  remote_repo.to_s.end_with?("/linuxbrew-core") || remote_repo == "Linuxbrew/homebrew-core"
end

#new_formula_path(name) ⇒ Pathname

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.

Parameters:

Returns:



1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
# File 'tap.rb', line 1251

def new_formula_path(name)
  formula_subdir = if name.start_with?("lib")
    "lib"
  else
    name[0].to_s
  end

  return super unless (formula_dir/formula_subdir).directory?

  formula_dir/formula_subdir/"#{name.downcase}.rb"
end

#pypi_formula_mappingsHash

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.

Returns:



1320
1321
1322
1323
1324
1325
# File 'tap.rb', line 1320

def pypi_formula_mappings
  @pypi_formula_mappings ||= begin
    ensure_installed!
    super
  end
end

#remoteString?

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.

Returns:



1203
1204
1205
1206
1207
# File 'tap.rb', line 1203

def remote
  return super if Homebrew::EnvConfig.no_install_from_api?

  Homebrew::EnvConfig.core_git_remote
end

#style_exceptionsHash

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.

Returns:



1312
1313
1314
1315
1316
1317
# File 'tap.rb', line 1312

def style_exceptions
  @style_exceptions ||= begin
    ensure_installed!
    super
  end
end

#synced_versions_formulaeArray<Array<String>>

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.

Returns:



1328
1329
1330
1331
1332
1333
# File 'tap.rb', line 1328

def synced_versions_formulae
  @synced_versions_formulae ||= begin
    ensure_installed!
    super
  end
end

#tap_migrationsHash

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.

Returns:



1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
# File 'tap.rb', line 1282

def tap_migrations
  @tap_migrations ||= if Homebrew::EnvConfig.no_install_from_api?
    ensure_installed!
    super
  elsif Homebrew::API.internal_json_v3?
    Homebrew::API::Formula.tap_migrations
  else
    migrations, = Homebrew::API.fetch_json_api_file "formula_tap_migrations.jws.json",
                                                    stale_seconds: TAP_MIGRATIONS_STALE_SECONDS
    migrations
  end
end

#to_internal_api_hashHash{String => T.untyped}

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.

Returns:



1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
# File 'tap.rb', line 1381

def to_internal_api_hash
  formulae_api_hash = formula_names.to_h do |name|
    formula = Formulary.factory(name)
    formula_hash = formula.to_hash_with_variations(hash_method: :to_internal_api_hash)
    [name, formula_hash]
  end

  {
    "tap_git_head"   => git_head,
    "aliases"        => alias_table,
    "renames"        => formula_renames,
    "tap_migrations" => tap_migrations,
    "formulae"       => formulae_api_hash,
  }
end

#uninstall(manual: false) ⇒ 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.

Parameters:

  • manual (Boolean) (defaults to: false)


1226
1227
1228
1229
1230
# File 'tap.rb', line 1226

def uninstall(manual: false)
  raise "Tap#uninstall is not available for CoreTap" if Homebrew::EnvConfig.no_install_from_api?

  super
end