mirror of
https://github.com/Homebrew/brew.git
synced 2024-11-25 16:33:34 +08:00
Use repository consistently instead of repo
The documentation linting job doesn't like `repo` so let's fix this globally rather than naming it differently in documentation and code.
This commit is contained in:
parent
f8b1d1f56c
commit
c13700af00
@ -55,8 +55,8 @@ module Homebrew
|
||||
|
||||
# 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
|
||||
|
@ -146,7 +146,7 @@ module Homebrew
|
||||
|
||||
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 @@ module Homebrew
|
||||
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
|
||||
|
@ -130,7 +130,7 @@ module Homebrew
|
||||
|
||||
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)
|
||||
|
@ -98,7 +98,7 @@ module Homebrew
|
||||
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
|
||||
|
@ -95,7 +95,7 @@ module Homebrew
|
||||
_, 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 @@ module Homebrew
|
||||
|
||||
# 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",
|
||||
|
@ -127,7 +127,7 @@ module Homebrew
|
||||
|
||||
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 @@ module Homebrew
|
||||
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 @@ module Homebrew
|
||||
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 @@ module Homebrew
|
||||
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?
|
||||
|
@ -289,8 +289,7 @@ class Formula
|
||||
|
||||
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
|
||||
|
@ -16,9 +16,11 @@ class GitRepository
|
||||
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)) }
|
||||
|
@ -9,10 +9,10 @@ require "settings"
|
||||
|
||||
# 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 @@ class Tap
|
||||
# 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 @@ class Tap
|
||||
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 @@ class Tap
|
||||
|
||||
# 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 @@ class Tap
|
||||
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 @@ class Tap
|
||||
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 @@ class Tap
|
||||
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 @@ class Tap
|
||||
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 @@ class Tap
|
||||
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 @@ class Tap
|
||||
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
|
||||
|
||||
|
@ -99,8 +99,8 @@ RSpec.describe Homebrew::DevCmd::PrPull do
|
||||
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 @@ RSpec.describe Homebrew::DevCmd::PrPull do
|
||||
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 @@ RSpec.describe Homebrew::DevCmd::PrPull do
|
||||
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
|
||||
|
||||
|
@ -695,7 +695,7 @@ module GitHub
|
||||
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] || "-"
|
||||
|
@ -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 <URL>`, where `user` and `repo` will be used to refer to your tap and `<URL>` 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 <URL>`, where `user` and `repository` will be used to refer to your tap and `<URL>` 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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user