diff --git a/Library/Homebrew/attestation.rb b/Library/Homebrew/attestation.rb index aa8d8f54223f2..4ec51c28711d2 100644 --- a/Library/Homebrew/attestation.rb +++ b/Library/Homebrew/attestation.rb @@ -55,8 +55,8 @@ def self.gh_executable # Verifies the given bottle against a cryptographic attestation of build provenance. # - # The provenance is verified as originating from `signing_repo`, which is a `String` - # that should be formatted as a GitHub `owner/repo`. + # The provenance is verified as originating from `signing_repository`, which is a `String` + # that should be formatted as a GitHub `owner/repository`. # # Callers may additionally pass in `signing_workflow`, which will scope the attestation # down to an exact GitHub Actions workflow, in diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 122ef265a206d..a76484e158883 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -146,7 +146,7 @@ def output_update_report updated_taps = [] Tap.installed.each do |tap| - next if !tap.git? || tap.git_repo.origin_url.nil? + next if !tap.git? || tap.git_repository.origin_url.nil? next if (tap.core_tap? || tap.core_cask_tap?) && !Homebrew::EnvConfig.no_install_from_api? if ENV["HOMEBREW_MIGRATE_LINUXBREW_FORMULAE"].present? && tap.core_tap? && @@ -321,7 +321,7 @@ def tap_or_untap_core_taps_if_necessary next unless tap.installed? if tap.git_branch == "master" && - (Date.parse(T.must(tap.git_repo.last_commit_date)) <= Date.today.prev_month) + (Date.parse(T.must(tap.git_repository.last_commit_date)) <= Date.today.prev_month) ohai "#{tap.name} is old and unneeded, untapping to save space..." tap.uninstall else diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 83f2f1e42cfdc..1bbbc6b9d8c50 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -130,7 +130,7 @@ def run tap_remote_repo = formula.tap.full_name || formula.tap.remote_repo remote = "origin" - remote_branch = formula.tap.git_repo.origin_branch_name + remote_branch = formula.tap.git_repository.origin_branch_name previous_branch = "-" check_open_pull_requests(formula, tap_remote_repo) diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index 40144dd57173e..a69e22bf7ed92 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -98,7 +98,7 @@ def run end odie "Could not find #{name}! The formula or version may not have existed." if test_formula.nil? else - # Search in the root directory of `repo` as well as recursively in all of its subdirectories. + # Search in the root directory of `repository` as well as recursively in all of its subdirectories. files = Dir[repo/"{,**/}"].filter_map do |dir| Pathname.glob("#{dir}/#{name}.rb").find(&:file?) end diff --git a/Library/Homebrew/dev-cmd/pr-pull.rb b/Library/Homebrew/dev-cmd/pr-pull.rb index a44279eced579..c880c436308a2 100644 --- a/Library/Homebrew/dev-cmd/pr-pull.rb +++ b/Library/Homebrew/dev-cmd/pr-pull.rb @@ -95,7 +95,7 @@ def run _, user, repo, pr = *url_match odie "Not a GitHub pull request: #{arg}" unless pr - git_repo = tap.git_repo + git_repo = tap.git_repository if !git_repo.default_origin_branch? && !args.branch_okay? && !args.no_commit? && !args.no_cherry_pick? origin_branch_name = git_repo.origin_branch_name opoo "Current branch is #{git_repo.branch_name}: do you need to pull inside #{origin_branch_name}?" @@ -341,7 +341,7 @@ def squash_package_commits(commits, file, git_repo:, reason: "", verbose: false, # TODO: fix test in `test/dev-cmd/pr-pull_spec.rb` and assume `cherry_picked: false`. def autosquash!(original_commit, tap:, reason: "", verbose: false, resolve: false, cherry_picked: true) - git_repo = tap.git_repo + git_repo = tap.git_repository original_head = git_repo.head_ref commits = Utils.safe_popen_read("git", "-C", tap.path, "rev-list", diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 54398793e7104..950279a846b5f 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -127,7 +127,7 @@ def please_create_pull_requests(what = "unsupported configuration") sig { params(repository_path: GitRepository, desired_origin: String).returns(T.nilable(String)) } def examine_git_origin(repository_path, desired_origin) - return if !Utils::Git.available? || !repository_path.git_repo? + return if !Utils::Git.available? || !repository_path.git_repository? current_origin = repository_path.origin_url @@ -156,7 +156,7 @@ def broken_tap(tap) return unless Utils::Git.available? repo = GitRepository.new(HOMEBREW_REPOSITORY) - return unless repo.git_repo? + return unless repo.git_repository? message = <<~EOS #{tap.full_name} was not tapped properly! Run: @@ -528,14 +528,14 @@ def check_coretap_integrity core_tap.ensure_installed! end - broken_tap(core_tap) || examine_git_origin(core_tap.git_repo, Homebrew::EnvConfig.core_git_remote) + broken_tap(core_tap) || examine_git_origin(core_tap.git_repository, Homebrew::EnvConfig.core_git_remote) end def check_casktap_integrity core_cask_tap = CoreCaskTap.instance return unless core_cask_tap.installed? - broken_tap(core_cask_tap) || examine_git_origin(core_cask_tap.git_repo, core_cask_tap.remote) + broken_tap(core_cask_tap) || examine_git_origin(core_cask_tap.git_repository, core_cask_tap.remote) end sig { returns(T.nilable(String)) } @@ -544,9 +544,9 @@ def check_tap_git_branch return unless Utils::Git.available? commands = Tap.installed.filter_map do |tap| - next if tap.git_repo.default_origin_branch? + next if tap.git_repository.default_origin_branch? - "git -C $(brew --repo #{tap.name}) checkout #{tap.git_repo.origin_branch_name}" + "git -C $(brew --repo #{tap.name}) checkout #{tap.git_repository.origin_branch_name}" end return if commands.blank? diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 7cdbba9b2441e..6bf5a1203f683 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -289,8 +289,7 @@ def build=(build_options) private - # Allow full name logic to be re-used between names, aliases, - # and installed aliases. + # Allow full name logic to be re-used between names, aliases and installed aliases. def full_name_with_optional_tap(name) if name.nil? || @tap.nil? || @tap.core_tap? name diff --git a/Library/Homebrew/git_repository.rb b/Library/Homebrew/git_repository.rb index 5e03a72c1e768..c8c36e36c2ac8 100644 --- a/Library/Homebrew/git_repository.rb +++ b/Library/Homebrew/git_repository.rb @@ -16,9 +16,11 @@ def initialize(pathname) end sig { returns(T::Boolean) } - def git_repo? + def git_repository? pathname.join(".git").exist? end + # odeprecated: use git_repository? instead + alias git_repo? git_repository? # Gets the URL of the Git origin remote. sig { returns(T.nilable(String)) } diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 6a0dfd7ec599e..d04fdec0c7b9c 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -9,10 +9,10 @@ # A {Tap} is used to extend the formulae provided by Homebrew core. # Usually, it's synced with a remote Git repository. And it's likely -# a GitHub repository with the name of `user/homebrew-repo`. In such -# cases, `user/repo` will be used as the {#name} of this {Tap}, where -# {#user} represents the GitHub username and {#repo} represents the repository -# name without the leading `homebrew-`. +# a GitHub repository with the name of `user/homebrew-repository`. In such +# cases, `user/repository` will be used as the {#name} of this {Tap}, where +# {#user} represents the GitHub username and {#repository} represents the +# repository name without the leading `homebrew-`. class Tap extend Cachable @@ -160,11 +160,13 @@ def self.forbidden_taps # The repository name of this {Tap} without the leading `homebrew-`. # # @api public - attr_reader :repo + attr_reader :repository + # odeprecated: use repository instead. + alias repo repository - # The name of this {Tap}. It combines {#user} and {#repo} with a slash. + # The name of this {Tap}. It combines {#user} and {#repository} with a slash. # {#name} is always in lowercase. - # e.g. `user/repo` + # e.g. `user/repository` # # @api public attr_reader :name @@ -174,14 +176,14 @@ def self.forbidden_taps def to_s = name # The full name of this {Tap}, including the `homebrew-` prefix. - # It combines {#user} and 'homebrew-'-prefixed {#repo} with a slash. - # e.g. `user/homebrew-repo` + # It combines {#user} and 'homebrew-'-prefixed {#repository} with a slash. + # e.g. `user/homebrew-repository` # # @api public attr_reader :full_name # The local path to this {Tap}. - # e.g. `/usr/local/Library/Taps/user/homebrew-repo` + # e.g. `/usr/local/Library/Taps/user/homebrew-repository` # # @api public sig { returns(Pathname) } @@ -189,24 +191,24 @@ def to_s = name # The git repository of this {Tap}. sig { returns(GitRepository) } - attr_reader :git_repo + attr_reader :git_repository # Always use `Tap.fetch` instead of `Tap.new`. private_class_method :new - def initialize(user, repo) + def initialize(user, repository) @user = user - @repo = repo - @name = "#{@user}/#{@repo}".downcase - @full_name = "#{@user}/homebrew-#{@repo}" + @repository = repository + @name = "#{@user}/#{@repository}".downcase + @full_name = "#{@user}/homebrew-#{@repository}" @path = TAP_DIRECTORY/@full_name.downcase - @git_repo = GitRepository.new(@path) + @git_repository = GitRepository.new(@path) end # Clear internal cache. def clear_cache @remote = nil - @repo_var_suffix = nil + @repository_var_suffix = nil remove_instance_variable(:@private) if instance_variable_defined?(:@private) @formula_dir = nil @@ -253,17 +255,17 @@ def ensure_installed! end # The remote path to this {Tap}. - # e.g. `https://github.com/user/homebrew-repo` + # e.g. `https://github.com/user/homebrew-repository` # # @api public def remote return default_remote unless installed? - @remote ||= git_repo.origin_url + @remote ||= git_repository.origin_url end # The remote repository name of this {Tap}. - # e.g. `user/homebrew-repo` + # e.g. `user/homebrew-repository` # # @api public sig { returns(T.nilable(String)) } @@ -282,18 +284,20 @@ def default_remote end sig { returns(String) } - def repo_var_suffix - @repo_var_suffix ||= path.to_s - .delete_prefix(TAP_DIRECTORY.to_s) - .tr("^A-Za-z0-9", "_") - .upcase + def repository_var_suffix + @repository_var_suffix ||= path.to_s + .delete_prefix(TAP_DIRECTORY.to_s) + .tr("^A-Za-z0-9", "_") + .upcase end + # odeprecated: use repository_var_suffix instead. + alias repo_var_suffix repository_var_suffix # Check whether this {Tap} is a Git repository. # # @api public def git? - git_repo.git_repo? + git_repository.git_repository? end # Git branch for this {Tap}. @@ -302,7 +306,7 @@ def git? def git_branch raise TapUnavailableError, name unless installed? - git_repo.branch_name + git_repository.branch_name end # Git HEAD for this {Tap}. @@ -311,7 +315,7 @@ def git_branch def git_head raise TapUnavailableError, name unless installed? - @git_head ||= git_repo.head_ref + @git_head ||= git_repository.head_ref end # Time since last git commit for this {Tap}. @@ -320,7 +324,7 @@ def git_head def git_last_commit raise TapUnavailableError, name unless installed? - git_repo.last_committed + git_repository.last_committed end # The issues URL of this {Tap}. @@ -564,22 +568,22 @@ def fix_remote_configuration(requested_remote: nil, quiet: false) end return unless remote - current_upstream_head = T.must(git_repo.origin_branch_name) - return if requested_remote.blank? && git_repo.origin_has_branch?(current_upstream_head) + current_upstream_head = T.must(git_repository.origin_branch_name) + return if requested_remote.blank? && git_repository.origin_has_branch?(current_upstream_head) args = %w[fetch] args << "--quiet" if quiet args << "origin" args << "+refs/heads/*:refs/remotes/origin/*" safe_system "git", "-C", path, *args - git_repo.set_head_origin_auto + git_repository.set_head_origin_auto - new_upstream_head = T.must(git_repo.origin_branch_name) + new_upstream_head = T.must(git_repository.origin_branch_name) return if new_upstream_head == current_upstream_head safe_system "git", "-C", path, "config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*" - git_repo.rename_branch old: current_upstream_head, new: new_upstream_head - git_repo.set_upstream_branch local: new_upstream_head, origin: new_upstream_head + git_repository.rename_branch old: current_upstream_head, new: new_upstream_head + git_repository.set_upstream_branch local: new_upstream_head, origin: new_upstream_head return if quiet diff --git a/Library/Homebrew/test/dev-cmd/pr-pull_spec.rb b/Library/Homebrew/test/dev-cmd/pr-pull_spec.rb index 8850c1cb989cd..777d4c25b5c6a 100644 --- a/Library/Homebrew/test/dev-cmd/pr-pull_spec.rb +++ b/Library/Homebrew/test/dev-cmd/pr-pull_spec.rb @@ -99,8 +99,8 @@ class Foo < Formula File.write(formula_file, formula_version) safe_system Utils::Git.git, "commit", formula_file, "-m", "version", "--author=#{secondary_author}" pr_pull.autosquash!(original_hash, tap:) - expect(tap.git_repo.commit_message).to include("foo 2.0") - expect(tap.git_repo.commit_message).to include("Co-authored-by: #{secondary_author}") + expect(tap.git_repository.commit_message).to include("foo 2.0") + expect(tap.git_repository.commit_message).to include("Co-authored-by: #{secondary_author}") end (path/"Casks").mkpath @@ -130,8 +130,8 @@ class Foo < Formula safe_system Utils::Git.git, "add", formula_file safe_system Utils::Git.git, "commit", "-m", "foo 1.0 (new formula)" end - pr_pull.signoff!(tap.git_repo) - expect(tap.git_repo.commit_message).to include("Signed-off-by:") + pr_pull.signoff!(tap.git_repository) + expect(tap.git_repository.commit_message).to include("Signed-off-by:") (path/"Casks").mkpath cask_file.write(cask) @@ -139,8 +139,8 @@ class Foo < Formula safe_system Utils::Git.git, "add", cask_file safe_system Utils::Git.git, "commit", "-m", "food 1.0 (new cask)" end - pr_pull.signoff!(tap.git_repo) - expect(tap.git_repo.commit_message).to include("Signed-off-by:") + pr_pull.signoff!(tap.git_repository) + expect(tap.git_repository.commit_message).to include("Signed-off-by:") end end diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 443a894ff8165..2b0c11a98968f 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -695,7 +695,7 @@ def self.create_bump_pr(info, args:) old_contents = info[:old_contents] additional_files = info[:additional_files] || [] remote = info[:remote] || "origin" - remote_branch = info[:remote_branch] || tap.git_repo.origin_branch_name + remote_branch = info[:remote_branch] || tap.git_repository.origin_branch_name branch = info[:branch_name] commit_message = info[:commit_message] previous_branch = info[:previous_branch] || "-" diff --git a/docs/How-to-Create-and-Maintain-a-Tap.md b/docs/How-to-Create-and-Maintain-a-Tap.md index 995f74fd045ce..9a5fcf5c1db91 100644 --- a/docs/How-to-Create-and-Maintain-a-Tap.md +++ b/docs/How-to-Create-and-Maintain-a-Tap.md @@ -18,9 +18,9 @@ If a formula in your tap has the same name as a Homebrew/homebrew-core formula t ## Installing -If it’s on GitHub, users can install any of your formulae with `brew install user/repo/formula`. Homebrew will automatically add your `github.com/user/homebrew-repo` tap before installing the formula. `user/repo/formula` points to the `github.com/user/homebrew-repo/**/formula.rb` file here. +If it’s on GitHub, users can install any of your formulae with `brew install user/repo/formula`. Homebrew will automatically add your `github.com/user/homebrew-repository` tap before installing the formula. `user/repo/formula` points to the `github.com/user/homebrew-repo/**/formula.rb` file here. -To install your tap without installing any formula at the same time, users can add it with the [`brew tap` command](Taps.md). If it’s on GitHub, they can use `brew tap user/repo`, where `user` is your GitHub username and `homebrew-repo` is your repository. If it’s hosted outside of GitHub, they have to use `brew tap user/repo `, where `user` and `repo` will be used to refer to your tap and `` is your Git clone URL. +To install your tap without installing any formula at the same time, users can add it with the [`brew tap` command](Taps.md). If it’s on GitHub, they can use `brew tap user/repository`, where `user` is your GitHub username and `homebrew-repository` is your repository. If it’s hosted outside of GitHub, they have to use `brew tap user/repo `, where `user` and `repository` will be used to refer to your tap and `` is your Git clone URL. Users can then install your formulae either with `brew install foo` if there’s no core formula with the same name, or with `brew install user/repo/foo` to avoid conflicts.