language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | Homebrew | brew | b7847e4657a84e80d97ce1582658058eca91cdbf.json | Don’t migrate symlinks. | Library/Homebrew/update_migrator/cache_entries_to_symlinks.rb | @@ -29,6 +29,7 @@ def migrate_cache_entries_to_symlinks(initial_version)
formula_downloaders = if HOMEBREW_CACHE.directory?
HOMEBREW_CACHE.children
+ .reject(&:symlink?)
.select(&:file?)
.map { |child| child.basename.to_s.sub(/\-\-.*/, "") }
.uniq
@@ -42,6 +43,8 @@ def migrate_cache_entries_to_symlinks(initial_version)
cask_downloaders = if (HOMEBREW_CACHE/"Cask").directory?
(HOMEBREW_CACHE/"Cask").children
+ .reject(&:symlink?)
+ .select(&:file?)
.map { |child| child.basename.to_s.sub(/\-\-.*/, "") }
.uniq
.map(&load_cask) | false |
Other | Homebrew | brew | 398845891938879f3df3772102903827b4e76b17.json | Use real basename for output. | Library/Homebrew/download_strategy.rb | @@ -11,7 +11,7 @@ class AbstractDownloadStrategy
module Pourable
def stage
- ohai "Pouring #{cached_location.basename}"
+ ohai "Pouring #{basename}"
super
end
end
@@ -85,7 +85,7 @@ def clear_cache
end
def basename
- nil
+ cached_location.basename
end
private | false |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/brew.rb | @@ -14,6 +14,8 @@
require_relative "global"
+require "update_migrator"
+
begin
trap("INT", std_trap) # restore default CTRL-C handler
@@ -76,7 +78,7 @@
end
# Migrate LinkedKegs/PinnedKegs if update didn't already do so
- migrate_legacy_keg_symlinks_if_necessary
+ UpdateMigrator.migrate_legacy_keg_symlinks_if_necessary
# Uninstall old brew-cask if it's still around; we just use the tap now.
if cmd == "cask" && (HOMEBREW_CELLAR/"brew-cask").exist? | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/cmd/update-report.rb | @@ -7,7 +7,7 @@
require "formulary"
require "descriptions"
require "cleanup"
-require "hbc/download"
+require "update_migrator"
module Homebrew
module_function
@@ -111,10 +111,10 @@ def update_report
updated = true
end
- migrate_legacy_cache_if_necessary
- migrate_cache_entries_to_double_dashes(initial_version)
- migrate_cache_entries_to_symlinks(initial_version)
- migrate_legacy_keg_symlinks_if_necessary
+ UpdateMigrator.migrate_legacy_cache_if_necessary
+ UpdateMigrator.migrate_cache_entries_to_double_dashes(initial_version)
+ UpdateMigrator.migrate_cache_entries_to_symlinks(initial_version)
+ UpdateMigrator.migrate_legacy_keg_symlinks_if_necessary
if !updated
if !ARGV.include?("--preinstall") && !ENV["HOMEBREW_UPDATE_FAILED"]
@@ -140,7 +140,7 @@ def update_report
# This should always be the last thing to run (but skip on auto-update).
if !ARGV.include?("--preinstall") ||
ENV["HOMEBREW_ENABLE_AUTO_UPDATE_MIGRATION"]
- migrate_legacy_repository_if_necessary
+ UpdateMigrator.migrate_legacy_repository_if_necessary
end
end
@@ -158,323 +158,6 @@ def install_core_tap_if_necessary
ENV["HOMEBREW_UPDATE_AFTER_HOMEBREW_HOMEBREW_CORE"] = revision
end
- def migrate_legacy_cache_if_necessary
- legacy_cache = Pathname.new "/Library/Caches/Homebrew"
- return if HOMEBREW_CACHE.to_s == legacy_cache.to_s
- return unless legacy_cache.directory?
- return unless legacy_cache.readable_real?
-
- migration_attempted_file = legacy_cache/".migration_attempted"
- return if migration_attempted_file.exist?
-
- return unless legacy_cache.writable_real?
- FileUtils.touch migration_attempted_file
-
- # This directory could have been compromised if it's world-writable/
- # a symlink/owned by another user so don't copy files in those cases.
- world_writable = legacy_cache.stat.mode & 0777 == 0777
- return if world_writable
- return if legacy_cache.symlink?
- return if !legacy_cache.owned? && legacy_cache.lstat.uid.nonzero?
-
- ohai "Migrating #{legacy_cache} to #{HOMEBREW_CACHE}..."
- HOMEBREW_CACHE.mkpath
- legacy_cache.cd do
- legacy_cache.entries.each do |f|
- next if [".", "..", ".migration_attempted"].include? f.to_s
- begin
- FileUtils.cp_r f, HOMEBREW_CACHE
- rescue
- @migration_failed ||= true
- end
- end
- end
-
- if @migration_failed
- opoo <<~EOS
- Failed to migrate #{legacy_cache} to
- #{HOMEBREW_CACHE}. Please do so manually.
- EOS
- else
- ohai "Deleting #{legacy_cache}..."
- FileUtils.rm_rf legacy_cache
- if legacy_cache.exist?
- FileUtils.touch migration_attempted_file
- opoo <<~EOS
- Failed to delete #{legacy_cache}.
- Please do so manually.
- EOS
- end
- end
- end
-
- def formula_resources(formula)
- specs = [formula.stable, formula.devel, formula.head].compact
-
- [*formula.bottle&.resource] + specs.flat_map do |spec|
- [
- spec,
- *spec.resources.values,
- *spec.patches.select(&:external?).map(&:resource),
- ]
- end
- end
-
- def parse_extname(url)
- uri_path = if URI::DEFAULT_PARSER.make_regexp =~ url
- uri = URI(url)
- uri.query ? "#{uri.path}?#{uri.query}" : uri.path
- else
- url
- end
-
- # Given a URL like https://example.com/download.php?file=foo-1.0.tar.gz
- # the extension we want is ".tar.gz", not ".php".
- Pathname.new(uri_path).ascend do |path|
- ext = path.extname[/[^?&]+/]
- return ext if ext
- end
-
- nil
- end
-
- def migrate_cache_entries_to_double_dashes(initial_version)
- return if initial_version && initial_version > "1.7.1"
-
- return if ENV.key?("HOMEBREW_DISABLE_LOAD_FORMULA")
-
- ohai "Migrating cache entries..."
-
- Formula.each do |formula|
- formula_resources(formula).each do |resource|
- downloader = resource.downloader
-
- url = downloader.url
- name = resource.download_name
- version = resource.version
-
- extname = parse_extname(url)
- old_location = downloader.cache/"#{name}-#{version}#{extname}"
- new_location = downloader.cache/"#{name}--#{version}#{extname}"
-
- next unless old_location.file?
-
- if new_location.exist?
- begin
- FileUtils.rm_rf old_location
- rescue Errno::EACCES
- opoo "Could not remove #{old_location}, please do so manually."
- end
- else
- begin
- FileUtils.mv old_location, new_location
- rescue Errno::EACCES
- opoo "Could not move #{old_location} to #{new_location}, please do so manually."
- end
- end
- end
- end
- end
-
- def migrate_cache_entries_to_symlinks(initial_version)
- return if initial_version && initial_version > "1.7.2"
-
- return if ENV.key?("HOMEBREW_DISABLE_LOAD_FORMULA")
-
- ohai "Migrating cache entries..."
-
- load_formula = lambda do |formula|
- begin
- Formula[formula]
- rescue FormulaUnavailableError
- nil
- end
- end
-
- load_cask = lambda do |cask|
- begin
- Hbc::CaskLoader.load(cask)
- rescue Hbc::CaskUnavailableError
- nil
- end
- end
-
- formula_downloaders = if HOMEBREW_CACHE.directory?
- HOMEBREW_CACHE.children
- .select(&:file?)
- .map { |child| child.basename.to_s.sub(/\-\-.*/, "") }
- .uniq
- .map(&load_formula)
- .compact
- .flat_map { |formula| formula_resources(formula) }
- .map { |resource| [resource.downloader, resource.download_name, resource.version] }
- else
- []
- end
-
- cask_downloaders = if (HOMEBREW_CACHE/"Cask").directory?
- (HOMEBREW_CACHE/"Cask").children
- .map { |child| child.basename.to_s.sub(/\-\-.*/, "") }
- .uniq
- .map(&load_cask)
- .compact
- .map { |cask| [Hbc::Download.new(cask).downloader, cask.token, cask.version] }
- else
- []
- end
-
- downloaders = formula_downloaders + cask_downloaders
-
- downloaders.each do |downloader, name, version|
- next unless downloader.respond_to?(:symlink_location)
-
- url = downloader.url
- extname = parse_extname(url)
- old_location = downloader.cache/"#{name}--#{version}#{extname}"
- next unless old_location.file?
-
- new_symlink_location = downloader.symlink_location
- new_location = downloader.cached_location
-
- if new_location.exist? && new_symlink_location.symlink?
- begin
- FileUtils.rm_rf old_location unless old_location == new_symlink_location
- rescue Errno::EACCES
- opoo "Could not remove #{old_location}, please do so manually."
- end
- else
- begin
- new_location.dirname.mkpath
- FileUtils.mv old_location, new_location unless new_location.exist?
- symlink_target = new_location.relative_path_from(new_symlink_location.dirname)
- new_symlink_location.dirname.mkpath
- FileUtils.ln_s symlink_target, new_symlink_location, force: true
- rescue Errno::EACCES
- opoo "Could not move #{old_location} to #{new_location}, please do so manually."
- end
- end
- end
- end
-
- def migrate_legacy_repository_if_necessary
- return unless HOMEBREW_PREFIX.to_s == "/usr/local"
- return unless HOMEBREW_REPOSITORY.to_s == "/usr/local"
-
- ohai "Migrating HOMEBREW_REPOSITORY (please wait)..."
-
- unless HOMEBREW_PREFIX.writable_real?
- ofail <<~EOS
- #{HOMEBREW_PREFIX} is not writable.
-
- You should change the ownership and permissions of #{HOMEBREW_PREFIX}
- temporarily back to your user account so we can complete the Homebrew
- repository migration:
- sudo chown -R $(whoami) #{HOMEBREW_PREFIX}
- EOS
- return
- end
-
- new_homebrew_repository = Pathname.new "/usr/local/Homebrew"
- new_homebrew_repository.rmdir_if_possible
- if new_homebrew_repository.exist?
- ofail <<~EOS
- #{new_homebrew_repository} already exists.
- Please remove it manually or uninstall and reinstall Homebrew into a new
- location as the migration cannot be done automatically.
- EOS
- return
- end
- new_homebrew_repository.mkpath
-
- repo_files = HOMEBREW_REPOSITORY.cd do
- Utils.popen_read("git ls-files").lines.map(&:chomp)
- end
-
- unless Utils.popen_read("git status --untracked-files=all --porcelain").empty?
- HOMEBREW_REPOSITORY.cd do
- quiet_system "git", "merge", "--abort"
- quiet_system "git", "rebase", "--abort"
- quiet_system "git", "reset", "--mixed"
- safe_system "git", "-c", "user.email=brew-update@localhost",
- "-c", "user.name=brew update",
- "stash", "save", "--include-untracked"
- end
- stashed = true
- end
-
- FileUtils.cp_r "#{HOMEBREW_REPOSITORY}/.git", "#{new_homebrew_repository}/.git"
- new_homebrew_repository.cd do
- safe_system "git", "checkout", "--force", "."
- safe_system "git", "stash", "pop" if stashed
- end
-
- if (HOMEBREW_REPOSITORY/"Library/Locks").exist?
- FileUtils.cp_r "#{HOMEBREW_REPOSITORY}/Library/Locks", "#{new_homebrew_repository}/Library/Locks"
- end
-
- if (HOMEBREW_REPOSITORY/"Library/Taps").exist?
- FileUtils.cp_r "#{HOMEBREW_REPOSITORY}/Library/Taps", "#{new_homebrew_repository}/Library/Taps"
- end
-
- unremovable_paths = []
- extra_remove_paths = [".git", "Library/Locks", "Library/Taps",
- "Library/Homebrew/cask", "Library/Homebrew/test"]
- (repo_files + extra_remove_paths).each do |file|
- path = Pathname.new "#{HOMEBREW_REPOSITORY}/#{file}"
- begin
- FileUtils.rm_rf path
- rescue Errno::EACCES
- unremovable_paths << path
- end
- quiet_system "rmdir", "-p", path.parent if path.parent.exist?
- end
-
- unless unremovable_paths.empty?
- ofail <<~EOS
- Could not remove old HOMEBREW_REPOSITORY paths!
- Please do this manually with:
- sudo rm -rf #{unremovable_paths.join " "}
- EOS
- end
-
- (Keg::ALL_TOP_LEVEL_DIRECTORIES + ["Cellar"]).each do |dir|
- FileUtils.mkdir_p "#{HOMEBREW_PREFIX}/#{dir}"
- end
-
- src = Pathname.new("#{new_homebrew_repository}/bin/brew")
- dst = Pathname.new("#{HOMEBREW_PREFIX}/bin/brew")
- begin
- FileUtils.ln_s(src.relative_path_from(dst.parent), dst)
- rescue Errno::EACCES, Errno::ENOENT
- ofail <<~EOS
- Could not create symlink at #{dst}!
- Please do this manually with:
- sudo ln -sf #{src} #{dst}
- sudo chown $(whoami) #{dst}
- EOS
- end
-
- link_completions_manpages_and_docs(new_homebrew_repository)
-
- ohai "Migrated HOMEBREW_REPOSITORY to #{new_homebrew_repository}!"
- puts <<~EOS
- Homebrew no longer needs to have ownership of /usr/local. If you wish you can
- return /usr/local to its default ownership with:
- sudo chown root:wheel #{HOMEBREW_PREFIX}
- EOS
- rescue => e
- ofail <<~EOS
- #{Tty.bold}Failed to migrate HOMEBREW_REPOSITORY to #{new_homebrew_repository}!#{Tty.reset}
- The error was:
- #{e}
- Please try to resolve this error yourself and then run `brew update` again to
- complete the migration. If you need help please +1 an existing error or comment
- with your new error in issue:
- #{Formatter.url("https://github.com/Homebrew/brew/issues/987")}
- EOS
- $stderr.puts e.backtrace
- end
-
def link_completions_manpages_and_docs(repository = HOMEBREW_REPOSITORY)
command = "brew update"
Utils::Link.link_completions(repository, command) | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/test/update_migrator_spec.rb | @@ -1,6 +1,6 @@
-require "cmd/update-report"
+require "update_migrator"
-describe "brew update-report" do
+describe UpdateMigrator do
describe "::migrate_cache_entries_to_double_dashes" do
let(:formula_name) { "foo" }
let(:f) {
@@ -18,7 +18,7 @@
end
it "moves old files to use double dashes when upgrading from <= 1.7.1" do
- Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
+ described_class.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
expect(old_cache_file).not_to exist
expect(new_cache_file).to exist
@@ -28,16 +28,16 @@
let(:formula_name) { "foo-bar" }
it "does not introduce extra double dashes when called multiple times" do
- Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
- Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
+ described_class.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
+ described_class.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
expect(old_cache_file).not_to exist
expect(new_cache_file).to exist
end
end
it "does not move files if upgrading from > 1.7.1" do
- Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.2"))
+ described_class.migrate_cache_entries_to_double_dashes(Version.new("1.7.2"))
expect(old_cache_file).to exist
expect(new_cache_file).not_to exist
@@ -63,7 +63,7 @@
end
it "moves old files to use symlinks when upgrading from <= 1.7.2" do
- Homebrew.migrate_cache_entries_to_symlinks(Version.new("1.7.2"))
+ described_class.migrate_cache_entries_to_symlinks(Version.new("1.7.2"))
expect(old_cache_file).to eq(new_cache_symlink)
expect(new_cache_symlink).to be_a_symlink
@@ -74,7 +74,7 @@
end
it "does not move files if upgrading from > 1.7.2" do
- Homebrew.migrate_cache_entries_to_symlinks(Version.new("1.7.3"))
+ described_class.migrate_cache_entries_to_symlinks(Version.new("1.7.3"))
expect(old_cache_file).to exist
expect(new_cache_file).not_to exist | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/update_migrator.rb | @@ -0,0 +1,39 @@
+require "update_migrator/cache_entries_to_double_dashes"
+require "update_migrator/cache_entries_to_symlinks"
+require "update_migrator/legacy_cache"
+require "update_migrator/legacy_keg_symlinks"
+require "update_migrator/legacy_repository"
+
+module UpdateMigrator
+ module_function
+
+ def formula_resources(formula)
+ specs = [formula.stable, formula.devel, formula.head].compact
+
+ [*formula.bottle&.resource] + specs.flat_map do |spec|
+ [
+ spec,
+ *spec.resources.values,
+ *spec.patches.select(&:external?).map(&:resource),
+ ]
+ end
+ end
+
+ def parse_extname(url)
+ uri_path = if URI::DEFAULT_PARSER.make_regexp =~ url
+ uri = URI(url)
+ uri.query ? "#{uri.path}?#{uri.query}" : uri.path
+ else
+ url
+ end
+
+ # Given a URL like https://example.com/download.php?file=foo-1.0.tar.gz
+ # the extension we want is ".tar.gz", not ".php".
+ Pathname.new(uri_path).ascend do |path|
+ ext = path.extname[/[^?&]+/]
+ return ext if ext
+ end
+
+ nil
+ end
+end | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/update_migrator/cache_entries_to_double_dashes.rb | @@ -0,0 +1,41 @@
+module UpdateMigrator
+ module_function
+
+ def migrate_cache_entries_to_double_dashes(initial_version)
+ return if initial_version && initial_version > "1.7.1"
+
+ return if ENV.key?("HOMEBREW_DISABLE_LOAD_FORMULA")
+
+ ohai "Migrating cache entries..."
+
+ Formula.each do |formula|
+ formula_resources(formula).each do |resource|
+ downloader = resource.downloader
+
+ url = downloader.url
+ name = resource.download_name
+ version = resource.version
+
+ extname = parse_extname(url)
+ old_location = downloader.cache/"#{name}-#{version}#{extname}"
+ new_location = downloader.cache/"#{name}--#{version}#{extname}"
+
+ next unless old_location.file?
+
+ if new_location.exist?
+ begin
+ FileUtils.rm_rf old_location
+ rescue Errno::EACCES
+ opoo "Could not remove #{old_location}, please do so manually."
+ end
+ else
+ begin
+ FileUtils.mv old_location, new_location
+ rescue Errno::EACCES
+ opoo "Could not move #{old_location} to #{new_location}, please do so manually."
+ end
+ end
+ end
+ end
+ end
+end | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/update_migrator/cache_entries_to_symlinks.rb | @@ -0,0 +1,90 @@
+require "hbc/cask_loader"
+require "hbc/download"
+
+module UpdateMigrator
+ module_function
+
+ def migrate_cache_entries_to_symlinks(initial_version)
+ return if initial_version && initial_version > "1.7.2"
+
+ return if ENV.key?("HOMEBREW_DISABLE_LOAD_FORMULA")
+
+ ohai "Migrating cache entries..."
+
+ load_formula = lambda do |formula|
+ begin
+ Formula[formula]
+ rescue FormulaUnavailableError
+ nil
+ end
+ end
+
+ load_cask = lambda do |cask|
+ begin
+ Hbc::CaskLoader.load(cask)
+ rescue Hbc::CaskUnavailableError
+ nil
+ end
+ end
+
+ formula_downloaders = if HOMEBREW_CACHE.directory?
+ HOMEBREW_CACHE.children
+ .select(&:file?)
+ .map { |child| child.basename.to_s.sub(/\-\-.*/, "") }
+ .uniq
+ .map(&load_formula)
+ .compact
+ .flat_map { |formula| formula_resources(formula) }
+ .map { |resource| [resource.downloader, resource.download_name, resource.version] }
+ else
+ []
+ end
+
+ cask_downloaders = if (HOMEBREW_CACHE/"Cask").directory?
+ (HOMEBREW_CACHE/"Cask").children
+ .map { |child| child.basename.to_s.sub(/\-\-.*/, "") }
+ .uniq
+ .map(&load_cask)
+ .compact
+ .map { |cask| [Hbc::Download.new(cask).downloader, cask.token, cask.version] }
+ else
+ []
+ end
+
+ downloaders = formula_downloaders + cask_downloaders
+
+ downloaders.each do |downloader, name, version|
+ next unless downloader.respond_to?(:symlink_location)
+
+ url = downloader.url
+ extname = parse_extname(url)
+ old_location = downloader.cache/"#{name}--#{version}#{extname}"
+ next unless old_location.file?
+
+ new_symlink_location = downloader.symlink_location
+ new_location = downloader.cached_location
+
+ if new_location.exist? && new_symlink_location.symlink?
+ begin
+ FileUtils.rm_rf old_location unless old_location == new_symlink_location
+ rescue Errno::EACCES
+ opoo "Could not remove #{old_location}, please do so manually."
+ end
+ else
+ begin
+ new_location.dirname.mkpath
+ if new_location.exist?
+ FileUtils.rm_rf old_location
+ else
+ FileUtils.mv old_location, new_location
+ end
+ symlink_target = new_location.relative_path_from(new_symlink_location.dirname)
+ new_symlink_location.dirname.mkpath
+ FileUtils.ln_s symlink_target, new_symlink_location, force: true
+ rescue Errno::EACCES
+ opoo "Could not move #{old_location} to #{new_location}, please do so manually."
+ end
+ end
+ end
+ end
+end | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/update_migrator/legacy_cache.rb | @@ -0,0 +1,53 @@
+module UpdateMigrator
+ module_function
+
+ def migrate_legacy_cache_if_necessary
+ legacy_cache = Pathname.new "/Library/Caches/Homebrew"
+ return if HOMEBREW_CACHE.to_s == legacy_cache.to_s
+ return unless legacy_cache.directory?
+ return unless legacy_cache.readable_real?
+
+ migration_attempted_file = legacy_cache/".migration_attempted"
+ return if migration_attempted_file.exist?
+
+ return unless legacy_cache.writable_real?
+ FileUtils.touch migration_attempted_file
+
+ # This directory could have been compromised if it's world-writable/
+ # a symlink/owned by another user so don't copy files in those cases.
+ world_writable = legacy_cache.stat.mode & 0777 == 0777
+ return if world_writable
+ return if legacy_cache.symlink?
+ return if !legacy_cache.owned? && legacy_cache.lstat.uid.nonzero?
+
+ ohai "Migrating #{legacy_cache} to #{HOMEBREW_CACHE}..."
+ HOMEBREW_CACHE.mkpath
+ legacy_cache.cd do
+ legacy_cache.entries.each do |f|
+ next if [".", "..", ".migration_attempted"].include? f.to_s
+ begin
+ FileUtils.cp_r f, HOMEBREW_CACHE
+ rescue
+ @migration_failed ||= true
+ end
+ end
+ end
+
+ if @migration_failed
+ opoo <<~EOS
+ Failed to migrate #{legacy_cache} to
+ #{HOMEBREW_CACHE}. Please do so manually.
+ EOS
+ else
+ ohai "Deleting #{legacy_cache}..."
+ FileUtils.rm_rf legacy_cache
+ if legacy_cache.exist?
+ FileUtils.touch migration_attempted_file
+ opoo <<~EOS
+ Failed to delete #{legacy_cache}.
+ Please do so manually.
+ EOS
+ end
+ end
+ end
+end | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/update_migrator/legacy_keg_symlinks.rb | @@ -0,0 +1,42 @@
+module UpdateMigrator
+ module_function
+
+ def migrate_legacy_keg_symlinks_if_necessary
+ legacy_linked_kegs = HOMEBREW_LIBRARY/"LinkedKegs"
+ return unless legacy_linked_kegs.directory?
+
+ HOMEBREW_LINKED_KEGS.mkpath unless legacy_linked_kegs.children.empty?
+ legacy_linked_kegs.children.each do |link|
+ name = link.basename.to_s
+ src = begin
+ link.realpath
+ rescue Errno::ENOENT
+ begin
+ (HOMEBREW_PREFIX/"opt/#{name}").realpath
+ rescue Errno::ENOENT
+ begin
+ Formulary.factory(name).installed_prefix
+ rescue
+ next
+ end
+ end
+ end
+ dst = HOMEBREW_LINKED_KEGS/name
+ dst.unlink if dst.exist?
+ FileUtils.ln_sf(src.relative_path_from(dst.parent), dst)
+ end
+ FileUtils.rm_rf legacy_linked_kegs
+
+ legacy_pinned_kegs = HOMEBREW_LIBRARY/"PinnedKegs"
+ return unless legacy_pinned_kegs.directory?
+
+ HOMEBREW_PINNED_KEGS.mkpath unless legacy_pinned_kegs.children.empty?
+ legacy_pinned_kegs.children.each do |link|
+ name = link.basename.to_s
+ src = link.realpath
+ dst = HOMEBREW_PINNED_KEGS/name
+ FileUtils.ln_sf(src.relative_path_from(dst.parent), dst)
+ end
+ FileUtils.rm_rf legacy_pinned_kegs
+ end
+end | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/update_migrator/legacy_repository.rb | @@ -0,0 +1,122 @@
+module UpdateMigrator
+ module_function
+
+ def migrate_legacy_repository_if_necessary
+ return unless HOMEBREW_PREFIX.to_s == "/usr/local"
+ return unless HOMEBREW_REPOSITORY.to_s == "/usr/local"
+
+ ohai "Migrating HOMEBREW_REPOSITORY (please wait)..."
+
+ unless HOMEBREW_PREFIX.writable_real?
+ ofail <<~EOS
+ #{HOMEBREW_PREFIX} is not writable.
+
+ You should change the ownership and permissions of #{HOMEBREW_PREFIX}
+ temporarily back to your user account so we can complete the Homebrew
+ repository migration:
+ sudo chown -R $(whoami) #{HOMEBREW_PREFIX}
+ EOS
+ return
+ end
+
+ new_homebrew_repository = Pathname.new "/usr/local/Homebrew"
+ new_homebrew_repository.rmdir_if_possible
+ if new_homebrew_repository.exist?
+ ofail <<~EOS
+ #{new_homebrew_repository} already exists.
+ Please remove it manually or uninstall and reinstall Homebrew into a new
+ location as the migration cannot be done automatically.
+ EOS
+ return
+ end
+ new_homebrew_repository.mkpath
+
+ repo_files = HOMEBREW_REPOSITORY.cd do
+ Utils.popen_read("git ls-files").lines.map(&:chomp)
+ end
+
+ unless Utils.popen_read("git status --untracked-files=all --porcelain").empty?
+ HOMEBREW_REPOSITORY.cd do
+ quiet_system "git", "merge", "--abort"
+ quiet_system "git", "rebase", "--abort"
+ quiet_system "git", "reset", "--mixed"
+ safe_system "git", "-c", "user.email=brew-update@localhost",
+ "-c", "user.name=brew update",
+ "stash", "save", "--include-untracked"
+ end
+ stashed = true
+ end
+
+ FileUtils.cp_r "#{HOMEBREW_REPOSITORY}/.git", "#{new_homebrew_repository}/.git"
+ new_homebrew_repository.cd do
+ safe_system "git", "checkout", "--force", "."
+ safe_system "git", "stash", "pop" if stashed
+ end
+
+ if (HOMEBREW_REPOSITORY/"Library/Locks").exist?
+ FileUtils.cp_r "#{HOMEBREW_REPOSITORY}/Library/Locks", "#{new_homebrew_repository}/Library/Locks"
+ end
+
+ if (HOMEBREW_REPOSITORY/"Library/Taps").exist?
+ FileUtils.cp_r "#{HOMEBREW_REPOSITORY}/Library/Taps", "#{new_homebrew_repository}/Library/Taps"
+ end
+
+ unremovable_paths = []
+ extra_remove_paths = [".git", "Library/Locks", "Library/Taps",
+ "Library/Homebrew/cask", "Library/Homebrew/test"]
+ (repo_files + extra_remove_paths).each do |file|
+ path = Pathname.new "#{HOMEBREW_REPOSITORY}/#{file}"
+ begin
+ FileUtils.rm_rf path
+ rescue Errno::EACCES
+ unremovable_paths << path
+ end
+ quiet_system "rmdir", "-p", path.parent if path.parent.exist?
+ end
+
+ unless unremovable_paths.empty?
+ ofail <<~EOS
+ Could not remove old HOMEBREW_REPOSITORY paths!
+ Please do this manually with:
+ sudo rm -rf #{unremovable_paths.join " "}
+ EOS
+ end
+
+ (Keg::ALL_TOP_LEVEL_DIRECTORIES + ["Cellar"]).each do |dir|
+ FileUtils.mkdir_p "#{HOMEBREW_PREFIX}/#{dir}"
+ end
+
+ src = Pathname.new("#{new_homebrew_repository}/bin/brew")
+ dst = Pathname.new("#{HOMEBREW_PREFIX}/bin/brew")
+ begin
+ FileUtils.ln_s(src.relative_path_from(dst.parent), dst)
+ rescue Errno::EACCES, Errno::ENOENT
+ ofail <<~EOS
+ Could not create symlink at #{dst}!
+ Please do this manually with:
+ sudo ln -sf #{src} #{dst}
+ sudo chown $(whoami) #{dst}
+ EOS
+ end
+
+ link_completions_manpages_and_docs(new_homebrew_repository)
+
+ ohai "Migrated HOMEBREW_REPOSITORY to #{new_homebrew_repository}!"
+ puts <<~EOS
+ Homebrew no longer needs to have ownership of /usr/local. If you wish you can
+ return /usr/local to its default ownership with:
+ sudo chown root:wheel #{HOMEBREW_PREFIX}
+ EOS
+ rescue => e
+ ofail <<~EOS
+ #{Tty.bold}Failed to migrate HOMEBREW_REPOSITORY to #{new_homebrew_repository}!#{Tty.reset}
+ The error was:
+ #{e}
+ Please try to resolve this error yourself and then run `brew update` again to
+ complete the migration. If you need help please +1 an existing error or comment
+ with your new error in issue:
+ #{Formatter.url("https://github.com/Homebrew/brew/issues/987")}
+ EOS
+ $stderr.puts e.backtrace
+ end
+end | true |
Other | Homebrew | brew | 516a39f5a471822b0565ae24189cc5389caaf923.json | Move migrations into `UpdateMigrator` module. | Library/Homebrew/utils.rb | @@ -498,45 +498,6 @@ def truncate_text_to_approximate_size(s, max_bytes, options = {})
out
end
-def migrate_legacy_keg_symlinks_if_necessary
- legacy_linked_kegs = HOMEBREW_LIBRARY/"LinkedKegs"
- return unless legacy_linked_kegs.directory?
-
- HOMEBREW_LINKED_KEGS.mkpath unless legacy_linked_kegs.children.empty?
- legacy_linked_kegs.children.each do |link|
- name = link.basename.to_s
- src = begin
- link.realpath
- rescue Errno::ENOENT
- begin
- (HOMEBREW_PREFIX/"opt/#{name}").realpath
- rescue Errno::ENOENT
- begin
- Formulary.factory(name).installed_prefix
- rescue
- next
- end
- end
- end
- dst = HOMEBREW_LINKED_KEGS/name
- dst.unlink if dst.exist?
- FileUtils.ln_sf(src.relative_path_from(dst.parent), dst)
- end
- FileUtils.rm_rf legacy_linked_kegs
-
- legacy_pinned_kegs = HOMEBREW_LIBRARY/"PinnedKegs"
- return unless legacy_pinned_kegs.directory?
-
- HOMEBREW_PINNED_KEGS.mkpath unless legacy_pinned_kegs.children.empty?
- legacy_pinned_kegs.children.each do |link|
- name = link.basename.to_s
- src = link.realpath
- dst = HOMEBREW_PINNED_KEGS/name
- FileUtils.ln_sf(src.relative_path_from(dst.parent), dst)
- end
- FileUtils.rm_rf legacy_pinned_kegs
-end
-
# Calls the given block with the passed environment variables
# added to ENV, then restores ENV afterwards.
# Example: | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/cask/lib/hbc/download.rb | @@ -1,4 +1,5 @@
require "fileutils"
+require "hbc/cache"
require "hbc/quarantine"
require "hbc/verify"
@@ -19,18 +20,18 @@ def perform
downloaded_path
end
- private
-
- attr_reader :force
- attr_accessor :downloaded_path
-
def downloader
@downloader ||= begin
strategy = DownloadStrategyDetector.detect(cask.url.to_s, cask.url.using)
strategy.new(cask.url.to_s, cask.token, cask.version, cache: Cache.path, **cask.url.specs)
end
end
+ private
+
+ attr_reader :force
+ attr_accessor :downloaded_path
+
def clear_cache
downloader.clear_cache if force || cask.version.latest?
end
@@ -39,7 +40,9 @@ def fetch
downloader.fetch
@downloaded_path = downloader.cached_location
rescue StandardError => e
- raise CaskError, "Download failed on Cask '#{cask}' with message: #{e}"
+ error = CaskError.new("Download failed on Cask '#{cask}' with message: #{e}")
+ error.set_backtrace e.backtrace
+ raise error
end
def quarantine | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/cleanup.rb | @@ -48,7 +48,7 @@ def prune?(days)
end
def stale?(scrub = false)
- return false unless file?
+ return false unless file? || (symlink? && resolved_path.file?)
stale_formula?(scrub) || stale_cask?(scrub)
end
@@ -209,6 +209,19 @@ def cleanup_logs
end
end
+ def cleanup_unreferenced_downloads
+ return if dry_run?
+ return unless (cache/"downloads").directory?
+
+ downloads = (cache/"downloads").children.reject { |path| path.incomplete? } # rubocop:disable Style/SymbolProc
+ referenced_downloads = [cache, cache/"Cask"].select(&:directory?)
+ .flat_map(&:children)
+ .select(&:symlink?)
+ .map(&:resolved_path)
+
+ (downloads - referenced_downloads).each(&:unlink)
+ end
+
def cleanup_cache(entries = nil)
entries ||= [cache, cache/"Cask"].select(&:directory?).flat_map(&:children)
@@ -217,7 +230,14 @@ def cleanup_cache(entries = nil)
next cleanup_path(path) { FileUtils.rm_rf path } if path.nested_cache?
if path.prune?(days)
- if path.file?
+ if path.symlink?
+ resolved_path = path.resolved_path
+
+ cleanup_path(path) do
+ resolved_path.unlink if resolved_path.exist?
+ path.unlink
+ end
+ elsif path.file?
cleanup_path(path) { path.unlink }
elsif path.directory? && path.to_s.include?("--")
cleanup_path(path) { FileUtils.rm_rf path }
@@ -227,6 +247,8 @@ def cleanup_cache(entries = nil)
next cleanup_path(path) { path.unlink } if path.stale?(scrub?)
end
+
+ cleanup_unreferenced_downloads
end
def cleanup_path(path) | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/cmd/update-report.rb | @@ -7,6 +7,7 @@
require "formulary"
require "descriptions"
require "cleanup"
+require "hbc/download"
module Homebrew
module_function
@@ -112,6 +113,7 @@ def update_report
migrate_legacy_cache_if_necessary
migrate_cache_entries_to_double_dashes(initial_version)
+ migrate_cache_entries_to_symlinks(initial_version)
migrate_legacy_keg_symlinks_if_necessary
if !updated
@@ -206,6 +208,36 @@ def migrate_legacy_cache_if_necessary
end
end
+ def formula_resources(formula)
+ specs = [formula.stable, formula.devel, formula.head].compact
+
+ [*formula.bottle&.resource] + specs.flat_map do |spec|
+ [
+ spec,
+ *spec.resources.values,
+ *spec.patches.select(&:external?).map(&:resource),
+ ]
+ end
+ end
+
+ def parse_extname(url)
+ uri_path = if URI::DEFAULT_PARSER.make_regexp =~ url
+ uri = URI(url)
+ uri.query ? "#{uri.path}?#{uri.query}" : uri.path
+ else
+ url
+ end
+
+ # Given a URL like https://example.com/download.php?file=foo-1.0.tar.gz
+ # the extension we want is ".tar.gz", not ".php".
+ Pathname.new(uri_path).ascend do |path|
+ ext = path.extname[/[^?&]+/]
+ return ext if ext
+ end
+
+ nil
+ end
+
def migrate_cache_entries_to_double_dashes(initial_version)
return if initial_version && initial_version > "1.7.1"
@@ -214,25 +246,16 @@ def migrate_cache_entries_to_double_dashes(initial_version)
ohai "Migrating cache entries..."
Formula.each do |formula|
- specs = [*formula.stable, *formula.devel, *formula.head]
-
- resources = [*formula.bottle&.resource] + specs.flat_map do |spec|
- [
- spec,
- *spec.resources.values,
- *spec.patches.select(&:external?).map(&:resource),
- ]
- end
-
- resources.each do |resource|
+ formula_resources(formula).each do |resource|
downloader = resource.downloader
+ url = downloader.url
name = resource.download_name
version = resource.version
- new_location = downloader.cached_location
- extname = new_location.extname
- old_location = downloader.cached_location.dirname/"#{name}-#{version}#{extname}"
+ extname = parse_extname(url)
+ old_location = downloader.cache/"#{name}-#{version}#{extname}"
+ new_location = downloader.cache/"#{name}--#{version}#{extname}"
next unless old_location.file?
@@ -253,6 +276,86 @@ def migrate_cache_entries_to_double_dashes(initial_version)
end
end
+ def migrate_cache_entries_to_symlinks(initial_version)
+ return if initial_version && initial_version > "1.7.2"
+
+ return if ENV.key?("HOMEBREW_DISABLE_LOAD_FORMULA")
+
+ ohai "Migrating cache entries..."
+
+ load_formula = lambda do |formula|
+ begin
+ Formula[formula]
+ rescue FormulaUnavailableError
+ nil
+ end
+ end
+
+ load_cask = lambda do |cask|
+ begin
+ Hbc::CaskLoader.load(cask)
+ rescue Hbc::CaskUnavailableError
+ nil
+ end
+ end
+
+ formula_downloaders = if HOMEBREW_CACHE.directory?
+ HOMEBREW_CACHE.children
+ .select(&:file?)
+ .map { |child| child.basename.to_s.sub(/\-\-.*/, "") }
+ .uniq
+ .map(&load_formula)
+ .compact
+ .flat_map { |formula| formula_resources(formula) }
+ .map { |resource| [resource.downloader, resource.download_name, resource.version] }
+ else
+ []
+ end
+
+ cask_downloaders = if (HOMEBREW_CACHE/"Cask").directory?
+ (HOMEBREW_CACHE/"Cask").children
+ .map { |child| child.basename.to_s.sub(/\-\-.*/, "") }
+ .uniq
+ .map(&load_cask)
+ .compact
+ .map { |cask| [Hbc::Download.new(cask).downloader, cask.token, cask.version] }
+ else
+ []
+ end
+
+ downloaders = formula_downloaders + cask_downloaders
+
+ downloaders.each do |downloader, name, version|
+ next unless downloader.respond_to?(:symlink_location)
+
+ url = downloader.url
+ extname = parse_extname(url)
+ old_location = downloader.cache/"#{name}--#{version}#{extname}"
+ next unless old_location.file?
+
+ new_symlink_location = downloader.symlink_location
+ new_location = downloader.cached_location
+
+ if new_location.exist? && new_symlink_location.symlink?
+ begin
+ FileUtils.rm_rf old_location unless old_location == new_symlink_location
+ rescue Errno::EACCES
+ opoo "Could not remove #{old_location}, please do so manually."
+ end
+ else
+ begin
+ new_location.dirname.mkpath
+ FileUtils.mv old_location, new_location unless new_location.exist?
+ symlink_target = new_location.relative_path_from(new_symlink_location.dirname)
+ new_symlink_location.dirname.mkpath
+ FileUtils.ln_s symlink_target, new_symlink_location, force: true
+ rescue Errno::EACCES
+ opoo "Could not move #{old_location} to #{new_location}, please do so manually."
+ end
+ end
+ end
+ end
+
def migrate_legacy_repository_if_necessary
return unless HOMEBREW_PREFIX.to_s == "/usr/local"
return unless HOMEBREW_REPOSITORY.to_s == "/usr/local" | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/dev-cmd/tests.rb | @@ -37,6 +37,7 @@ def tests
ENV.delete("HOMEBREW_COLOR")
ENV.delete("HOMEBREW_NO_COLOR")
ENV.delete("HOMEBREW_VERBOSE")
+ ENV.delete("HOMEBREW_DEBUG")
ENV.delete("VERBOSE")
ENV.delete("HOMEBREW_CASK_OPTS")
ENV.delete("HOMEBREW_TEMP") | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/download_strategy.rb | @@ -2,6 +2,8 @@
require "rexml/document"
require "time"
require "unpack_strategy"
+require "lazy_object"
+require "cgi"
class AbstractDownloadStrategy
extend Forwardable
@@ -14,7 +16,7 @@ def stage
end
end
- attr_reader :cached_location
+ attr_reader :cache, :cached_location, :url
attr_reader :meta, :name, :version, :shutup
private :meta, :name, :version, :shutup
@@ -51,7 +53,7 @@ def stage
UnpackStrategy.detect(cached_location,
extension_only: true,
ref_type: @ref_type, ref: @ref)
- .extract_nestedly(basename: basename_without_params,
+ .extract_nestedly(basename: basename,
extension_only: true,
verbose: ARGV.verbose? && !shutup)
chdir
@@ -82,11 +84,8 @@ def clear_cache
rm_rf(cached_location)
end
- def basename_without_params
- return unless @url
-
- # Strip any ?thing=wad out of .c?thing=wad style extensions
- File.basename(@url)[/[^?]+/]
+ def basename
+ nil
end
private
@@ -122,7 +121,7 @@ def initialize(url, name, version, **meta)
end
def fetch
- ohai "Cloning #{@url}"
+ ohai "Cloning #{url}"
if cached_location.exist? && repo_valid?
puts "Updating #{cached_location}"
@@ -193,30 +192,78 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
def initialize(url, name, version, **meta)
super
- @cached_location = @cache/"#{name}--#{version}#{ext}"
@temporary_path = Pathname.new("#{cached_location}.incomplete")
end
+ def symlink_location
+ return @symlink_location if defined?(@symlink_location)
+ ext = Pathname(parse_basename(url)).extname
+ @symlink_location = @cache/"#{name}--#{version}#{ext}"
+ end
+
+ def cached_location
+ return @cached_location if defined?(@cached_location)
+
+ url_sha256 = Digest::SHA256.hexdigest(url)
+ downloads = Pathname.glob(HOMEBREW_CACHE/"downloads/#{url_sha256}--*")
+
+ @cached_location = if downloads.count == 1
+ downloads.first
+ else
+ HOMEBREW_CACHE/"downloads/#{url_sha256}--#{resolved_basename}"
+ end
+ end
+
+ def basename
+ cached_location.basename.sub(/^[\da-f]{64}\-\-/, "")
+ end
+
private
- def ext
- uri_path = if URI::DEFAULT_PARSER.make_regexp =~ @url
- uri = URI(@url)
+ def resolved_url
+ resolved_url, = resolved_url_and_basename
+ resolved_url
+ end
+
+ def resolved_basename
+ _, resolved_basename = resolved_url_and_basename
+ resolved_basename
+ end
+
+ def resolved_url_and_basename
+ return @resolved_url_and_basename if defined?(@resolved_url_and_basename)
+ @resolved_url_and_basename = [url, parse_basename(url)]
+ end
+
+ def parse_basename(url)
+ uri_path = if URI::DEFAULT_PARSER.make_regexp =~ url
+ uri = URI(url)
+
+ if uri.query
+ query_params = CGI.parse(uri.query)
+ query_params["response-content-disposition"].each do |param|
+ query_basename = param[/attachment;\s*filename=(["']?)(.+)\1/i, 2]
+ return query_basename if query_basename
+ end
+ end
+
uri.query ? "#{uri.path}?#{uri.query}" : uri.path
else
- @url
+ url
end
+ uri_path = URI.decode_www_form_component(uri_path)
+
# We need a Pathname because we've monkeypatched extname to support double
# extensions (e.g. tar.gz).
- # We can't use basename_without_params, because given a URL like
- # https://example.com/download.php?file=foo-1.0.tar.gz
- # the extension we want is ".tar.gz", not ".php".
+ # Given a URL like https://example.com/download.php?file=foo-1.0.tar.gz
+ # the basename we want is "foo-1.0.tar.gz", not "download.php".
Pathname.new(uri_path).ascend do |path|
ext = path.extname[/[^?&]+/]
- return ext if ext
+ return path.basename.to_s[/[^?&]+#{Regexp.escape(ext)}/] if ext
end
- nil
+
+ File.basename(uri_path)
end
end
@@ -229,23 +276,34 @@ def initialize(url, name, version, **meta)
end
def fetch
- ohai "Downloading #{@url}"
+ urls = [url, *mirrors]
- if cached_location.exist?
- puts "Already downloaded: #{cached_location}"
- else
- begin
- _fetch
- rescue ErrorDuringExecution
- raise CurlDownloadStrategyError, @url
+ begin
+ url = urls.shift
+
+ ohai "Downloading #{url}"
+
+ if cached_location.exist?
+ puts "Already downloaded: #{cached_location}"
+ else
+ begin
+ resolved_url, = resolve_url_and_basename(url)
+
+ _fetch(url: url, resolved_url: resolved_url)
+ rescue ErrorDuringExecution
+ raise CurlDownloadStrategyError, url
+ end
+ ignore_interrupts do
+ temporary_path.rename(cached_location)
+ symlink_location.dirname.mkpath
+ FileUtils.ln_s cached_location.relative_path_from(symlink_location.dirname), symlink_location, force: true
+ end
end
- ignore_interrupts { temporary_path.rename(cached_location) }
+ rescue CurlDownloadStrategyError
+ raise if urls.empty?
+ puts "Trying a mirror..."
+ retry
end
- rescue CurlDownloadStrategyError
- raise if mirrors.empty?
- puts "Trying a mirror..."
- @url = mirrors.shift
- retry
end
def clear_cache
@@ -255,18 +313,52 @@ def clear_cache
private
- # Private method, can be overridden if needed.
- def _fetch
- url = @url
+ def resolved_url_and_basename
+ return @resolved_url_and_basename if defined?(@resolved_url_and_basename)
+ @resolved_url_and_basename = resolve_url_and_basename(url)
+ end
+ def resolve_url_and_basename(url)
if ENV["HOMEBREW_ARTIFACT_DOMAIN"]
url = url.sub(%r{^((ht|f)tps?://)?}, ENV["HOMEBREW_ARTIFACT_DOMAIN"].chomp("/") + "/")
- ohai "Downloading from #{url}"
end
+ out, _, status= curl_output("--location", "--silent", "--head", url.to_s)
+
+ lines = status.success? ? out.lines.map(&:chomp) : []
+
+ locations = lines.map { |line| line[/^Location:\s*(.*)$/i, 1] }
+ .compact
+
+ redirect_url = locations.reduce(url) do |current_url, location|
+ if location.start_with?("/")
+ uri = URI(current_url)
+ "#{uri.scheme}://#{uri.host}#{location}"
+ else
+ location
+ end
+ end
+
+ filenames = lines.map { |line| line[/^Content\-Disposition:\s*attachment;\s*filename=(["']?)(.+)\1$/i, 2] }
+ .compact
+
+ basename = filenames.last || parse_basename(redirect_url)
+
+ [redirect_url, basename]
+ end
+
+ def _fetch(url:, resolved_url:)
temporary_path.dirname.mkpath
- curl_download resolved_url(url), to: temporary_path
+ ohai "Downloading from #{resolved_url}" if url != resolved_url
+
+ if ENV["HOMEBREW_NO_INSECURE_REDIRECT"] &&
+ url.start_with?("https://") && !resolved_url.start_with?("https://")
+ $stderr.puts "HTTPS to HTTP redirect detected & HOMEBREW_NO_INSECURE_REDIRECT is set."
+ raise CurlDownloadStrategyError, url
+ end
+
+ curl_download resolved_url, to: temporary_path
end
# Curl options to be always passed to curl,
@@ -291,27 +383,6 @@ def _curl_opts
{}
end
- def resolved_url(url)
- redirect_url, _, status = curl_output(
- "--silent", "--head",
- "--write-out", "%{redirect_url}",
- "--output", "/dev/null",
- url.to_s
- )
-
- return url unless status.success?
- return url if redirect_url.empty?
-
- ohai "Downloading from #{redirect_url}"
- if ENV["HOMEBREW_NO_INSECURE_REDIRECT"] &&
- url.start_with?("https://") && !redirect_url.start_with?("https://")
- puts "HTTPS to HTTP redirect detected & HOMEBREW_NO_INSECURE_REDIRECT is set."
- raise CurlDownloadStrategyError, url
- end
-
- redirect_url
- end
-
def curl_output(*args, **options)
super(*_curl_args, *args, **_curl_opts, **options)
end
@@ -324,36 +395,45 @@ def curl(*args, **options)
# Detect and download from Apache Mirror
class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy
- def apache_mirrors
- mirrors, = curl_output("--silent", "--location", "#{@url}&asjson=1")
- JSON.parse(mirrors)
+ def mirrors
+ return @combined_mirrors if defined?(@combined_mirrors)
+
+ backup_mirrors = apache_mirrors.fetch("backup", [])
+ .map { |mirror| "#{mirror}#{apache_mirrors["path_info"]}" }
+
+ @combined_mirrors = [*@mirrors, *backup_mirrors]
end
- def _fetch
- return super if @tried_apache_mirror
- @tried_apache_mirror = true
+ private
- mirrors = apache_mirrors
- path_info = mirrors.fetch("path_info")
- @url = mirrors.fetch("preferred") + path_info
- @mirrors |= %W[https://archive.apache.org/dist/#{path_info}]
+ def resolved_url_and_basename
+ return @resolved_url_and_basename if defined?(@resolved_url_and_basename)
+ @resolved_url_and_basename = [
+ "#{apache_mirrors["preferred"]}#{apache_mirrors["path_info"]}",
+ File.basename(apache_mirrors["path_info"]),
+ ]
+ end
- ohai "Best Mirror #{@url}"
- super
- rescue IndexError, JSON::ParserError
+ def apache_mirrors
+ return @apache_mirrors if defined?(@apache_mirrors)
+ json, = curl_output("--silent", "--location", "#{url}&asjson=1")
+ @apache_mirrors = JSON.parse(json)
+ rescue JSON::ParserError
raise CurlDownloadStrategyError, "Couldn't determine mirror, try again later."
end
end
# Download via an HTTP POST.
# Query parameters on the URL are converted into POST parameters
class CurlPostDownloadStrategy < CurlDownloadStrategy
- def _fetch
+ private
+
+ def _fetch(url:, resolved_url:)
args = if meta.key?(:data)
escape_data = ->(d) { ["-d", URI.encode_www_form([d])] }
- [@url, *meta[:data].flat_map(&escape_data)]
+ [url, *meta[:data].flat_map(&escape_data)]
else
- url, query = @url.split("?", 2)
+ url, query = url.split("?", 2)
query.nil? ? [url, "-X", "POST"] : [url, "-d", query]
end
@@ -366,7 +446,7 @@ def _fetch
class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy
def stage
UnpackStrategy::Uncompressed.new(cached_location)
- .extract(basename: basename_without_params,
+ .extract(basename: basename,
verbose: ARGV.verbose? && !shutup)
end
end
@@ -386,10 +466,10 @@ def initialize(path)
# because it lets you use a private S3 bucket as a repo for internal
# distribution. (It will work for public buckets as well.)
class S3DownloadStrategy < CurlDownloadStrategy
- def _fetch
- if @url !~ %r{^https?://([^.].*)\.s3\.amazonaws\.com/(.+)$} &&
- @url !~ %r{^s3://([^.].*?)/(.+)$}
- raise "Bad S3 URL: " + @url
+ def _fetch(url:, resolved_url:)
+ if url !~ %r{^https?://([^.].*)\.s3\.amazonaws\.com/(.+)$} &&
+ url !~ %r{^s3://([^.].*?)/(.+)$}
+ raise "Bad S3 URL: " + url
end
bucket = Regexp.last_match(1)
key = Regexp.last_match(2)
@@ -402,7 +482,7 @@ def _fetch
s3url = signer.presigned_url :get_object, bucket: bucket, key: key
rescue Aws::Sigv4::Errors::MissingCredentialsError
ohai "AWS credentials missing, trying public URL instead."
- s3url = @url
+ s3url = url
end
curl_download s3url, to: temporary_path
@@ -428,24 +508,23 @@ def initialize(url, name, version, **meta)
end
def parse_url_pattern
- url_pattern = %r{https://github.com/([^/]+)/([^/]+)/(\S+)}
- unless @url =~ url_pattern
+ unless match = url.match(%r{https://github.com/([^/]+)/([^/]+)/(\S+)})
raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Repository."
end
- _, @owner, @repo, @filepath = *@url.match(url_pattern)
+ _, @owner, @repo, @filepath = *match
end
def download_url
"https://#{@github_token}@github.com/#{@owner}/#{@repo}/#{@filepath}"
end
- def _fetch
+ private
+
+ def _fetch(url:, resolved_url:)
curl_download download_url, to: temporary_path
end
- private
-
def set_github_token
@github_token = ENV["HOMEBREW_GITHUB_API_TOKEN"]
unless @github_token
@@ -486,14 +565,14 @@ def download_url
"https://#{@github_token}@api.github.com/repos/#{@owner}/#{@repo}/releases/assets/#{asset_id}"
end
- def _fetch
+ private
+
+ def _fetch(url:, resolved_url:)
# HTTP request header `Accept: application/octet-stream` is required.
# Without this, the GitHub API will respond with metadata, not binary.
curl_download download_url, "--header", "Accept: application/octet-stream", to: temporary_path
end
- private
-
def asset_id
@asset_id ||= resolve_asset_id
end | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/extend/pathname.rb | @@ -24,6 +24,12 @@ def abv
private
def compute_disk_usage
+ if symlink? && !exist?
+ @file_count = 1
+ @disk_usage = 0
+ return
+ end
+
path = if symlink?
resolved_path
else | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/test/cask/cli/reinstall_spec.rb | @@ -10,7 +10,7 @@
output = Regexp.new <<~EOS
==> Downloading file:.*caffeine.zip
- Already downloaded: .*local-caffeine--1.2.3.zip
+ Already downloaded: .*caffeine.zip
==> Verifying checksum for Cask local-caffeine
==> Uninstalling Cask local-caffeine
==> Backing App 'Caffeine.app' up to '.*Caffeine.app'. | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/test/cmd/--cache_spec.rb | @@ -8,7 +8,7 @@
it "prints all cache files for a given Formula" do
expect { brew "--cache", testball }
- .to output(%r{#{HOMEBREW_CACHE}/testball-}).to_stdout
+ .to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}\-\-testball\-}).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/test/cmd/fetch_spec.rb | @@ -2,10 +2,9 @@
it "downloads the Formula's URL" do
setup_test_formula "testball"
- expect(HOMEBREW_CACHE/"testball--0.1.tbz").not_to exist
-
expect { brew "fetch", "testball" }.to be_a_success
+ expect(HOMEBREW_CACHE/"testball--0.1.tbz").to be_a_symlink
expect(HOMEBREW_CACHE/"testball--0.1.tbz").to exist
end
end | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/test/cmd/update-report_spec.rb | @@ -43,4 +43,42 @@
expect(new_cache_file).not_to exist
end
end
+
+ describe "::migrate_cache_entries_to_symlinks" do
+ let(:formula_name) { "foo" }
+ let(:f) {
+ formula formula_name do
+ url "https://example.com/foo-1.2.3.tar.gz"
+ version "1.2.3"
+ end
+ }
+ let(:old_cache_file) { HOMEBREW_CACHE/"#{formula_name}--1.2.3.tar.gz" }
+ let(:new_cache_symlink) { HOMEBREW_CACHE/"#{formula_name}--1.2.3.tar.gz" }
+ let(:new_cache_file) { HOMEBREW_CACHE/"downloads/5994e3a27baa3f448a001fb071ab1f0bf25c87aebcb254d91a6d0b02f46eef86--foo-1.2.3.tar.gz" }
+
+ before(:each) do
+ old_cache_file.dirname.mkpath
+ FileUtils.touch old_cache_file
+ allow(Formula).to receive(:[]).and_return(f)
+ end
+
+ it "moves old files to use symlinks when upgrading from <= 1.7.2" do
+ Homebrew.migrate_cache_entries_to_symlinks(Version.new("1.7.2"))
+
+ expect(old_cache_file).to eq(new_cache_symlink)
+ expect(new_cache_symlink).to be_a_symlink
+ expect(new_cache_symlink.readlink.to_s)
+ .to eq "downloads/5994e3a27baa3f448a001fb071ab1f0bf25c87aebcb254d91a6d0b02f46eef86--foo-1.2.3.tar.gz"
+ expect(new_cache_file).to exist
+ expect(new_cache_file).to be_a_file
+ end
+
+ it "does not move files if upgrading from > 1.7.2" do
+ Homebrew.migrate_cache_entries_to_symlinks(Version.new("1.7.3"))
+
+ expect(old_cache_file).to exist
+ expect(new_cache_file).not_to exist
+ expect(new_cache_symlink).not_to be_a_symlink
+ end
+ end
end | true |
Other | Homebrew | brew | fbcaa8c85ae42f127fd94a5d82f86a3eafb34848.json | Resolve URL to get real file extension. | Library/Homebrew/test/download_strategies_spec.rb | @@ -207,16 +207,12 @@ def setup_git_repo
let(:url) { "https://bucket.s3.amazonaws.com/foo.tar.gz" }
let(:version) { nil }
- describe "#_fetch" do
- subject { described_class.new(url, name, version)._fetch }
-
+ describe "#fetch" do
context "when given Bad S3 URL" do
let(:url) { "https://example.com/foo.tar.gz" }
it "raises Bad S3 URL error" do
- expect {
- subject._fetch
- }.to raise_error(RuntimeError)
+ expect { subject.fetch }.to raise_error(RuntimeError, /S3/)
end
end
end
@@ -238,18 +234,19 @@ def setup_git_repo
subject { described_class.new(url, name, version, **specs).cached_location }
context "when URL ends with file" do
- it { is_expected.to eq(HOMEBREW_CACHE/"foo--1.2.3.tar.gz") }
+ it { is_expected.to eq(HOMEBREW_CACHE/"downloads/3d1c0ae7da22be9d83fb1eb774df96b7c4da71d3cf07e1cb28555cf9a5e5af70--foo.tar.gz") }
end
context "when URL file is in middle" do
let(:url) { "https://example.com/foo.tar.gz/from/this/mirror" }
- it { is_expected.to eq(HOMEBREW_CACHE/"foo--1.2.3.tar.gz") }
+ it { is_expected.to eq(HOMEBREW_CACHE/"downloads/1ab61269ba52c83994510b1e28dd04167a2f2e8393a35a9c50c1f7d33fd8f619--foo.tar.gz") }
end
end
describe "#fetch" do
before(:each) do
+ subject.temporary_path.dirname.mkpath
FileUtils.touch subject.temporary_path
end
@@ -330,11 +327,6 @@ def setup_git_repo
its("cached_location.extname") { is_expected.to eq(".dmg") }
end
- context "with no discernible file name in it" do
- let(:url) { "https://example.com/download" }
- its("cached_location.basename.to_path") { is_expected.to eq("foo--1.2.3") }
- end
-
context "with a file name trailing the first query parameter" do
let(:url) { "https://example.com/download?file=cask.zip&a=1" }
its("cached_location.extname") { is_expected.to eq(".zip") }
@@ -380,6 +372,7 @@ def setup_git_repo
describe "#fetch" do
before(:each) do
+ subject.temporary_path.dirname.mkpath
FileUtils.touch subject.temporary_path
end
| true |
Other | Homebrew | brew | b7b5fb930da5116277152a11044c187414aecef7.json | superenv: Use 02 optimization flag for Linux builds
`-Os` produces sometimes bigger binaries on Linux.
Also, llvm built with `-Os` is really slow at runtime for Linux.
Using `-02` aligns us with what Debian does, and as we are compiling most of our stuff with gcc (and not clang), it makes sense to use `-02` on Linux.
`-Os` does probably slightly different things when used on mac with llvm, compared to when it is used with gcc on Linux. | Library/Homebrew/extend/os/linux/extend/ENV/super.rb | @@ -7,6 +7,7 @@ def self.bin
# @private
def setup_build_environment(formula = nil)
generic_setup_build_environment(formula)
+ self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O2"
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(formula)
end | false |
Other | Homebrew | brew | ff711fcfad68eec3f40ac7206a8fde7fd1982a99.json | Maintainer-Guidelines: note consensus and final say. | docs/Maintainer-Guidelines.md | @@ -117,7 +117,7 @@ All communication should ideally occur in public on GitHub. Where this is not po
This makes it easier for other maintainers, contributors and users to follow along with what we're doing (and, more importantly, why we're doing it) and means that decisions have a linkable URL.
## Lead maintainer guidelines
-There should be one lead maintainer for Homebrew. This person should (sparingly) be the tiebreaker for decisions where a mutual consensus cannot be reached amongst other maintainers. They should also be seen as the product manager for Homebrew itself and ensuring that changes made to the entire Homebrew ecosystem are consistent and providing an increasingly positive experience for Homebrew's users.
+There should be one lead maintainer for Homebrew. Decisions are determined by a consensus of the maintainers. When a consensus is not reached, the lead maintainer has the final say in determining the outcome of any decision (though this power should be used sparingly). They should also be seen as the product manager for Homebrew itself and ensuring that changes made to the entire Homebrew ecosystem are consistent and providing an increasingly positive experience for Homebrew's users.
In the same way that Homebrew maintainers are expected to be spending more of their time reviewing and merging contributions from non-maintainer contributors than making their own contributions, the lead maintainer should be spending most of their time reviewing work from and mentoring other maintainers.
| false |
Other | Homebrew | brew | 23846d6ca82225c1e6941df199a1ea643981884b.json | audit: Add null check on style results | Library/Homebrew/dev-cmd/audit.rb | @@ -130,7 +130,7 @@ def audit
formula_count += 1
problem_count += fa.problems.size
problem_lines = format_problem_lines(fa.problems)
- corrected_problem_count = options[:style_offenses].count(&:corrected?)
+ corrected_problem_count = options[:style_offenses]&.count(&:corrected?)
new_formula_problem_lines = format_problem_lines(fa.new_formula_problems)
if args.display_filename?
puts problem_lines.map { |s| "#{f.path}: #{s}" } | false |
Other | Homebrew | brew | ca6c75d229c73a2523e95aa3736a8031c2f8c158.json | Check version conflicts using linkage.
Instead of refusing to install software preemptively by assuming
multiple linkage to differing versions of the same library we now make
`brew linkage --test` verify that we don't have two versions of the
same library linked at the same time.
This will be considerably more permissive whilst checking the actual
problem that we're worried about. | Library/Homebrew/formula_installer.rb | @@ -155,8 +155,6 @@ def check_install_sanity
recursive_deps = formula.recursive_dependencies
recursive_formulae = recursive_deps.map(&:to_formula)
- recursive_runtime_formulae =
- formula.runtime_formula_dependencies(undeclared: false)
recursive_dependencies = []
recursive_formulae.each do |dep|
@@ -182,25 +180,6 @@ def check_install_sanity
EOS
end
- version_hash = {}
- version_conflicts = Set.new
- recursive_runtime_formulae.each do |f|
- name = f.name
- unversioned_name, = name.split("@")
- next if unversioned_name == "python"
- version_hash[unversioned_name] ||= Set.new
- version_hash[unversioned_name] << name
- next if version_hash[unversioned_name].length < 2
- version_conflicts += version_hash[unversioned_name]
- end
- unless version_conflicts.empty?
- raise CannotInstallFormulaError, <<~EOS
- #{formula.full_name} contains conflicting version recursive dependencies:
- #{version_conflicts.to_a.join ", "}
- View these with `brew deps --tree #{formula.full_name}`.
- EOS
- end
-
pinned_unsatisfied_deps = recursive_deps.select do |dep|
dep.to_formula.pinned? && !dep.satisfied?(inherited_options_for(dep))
end | true |
Other | Homebrew | brew | ca6c75d229c73a2523e95aa3736a8031c2f8c158.json | Check version conflicts using linkage.
Instead of refusing to install software preemptively by assuming
multiple linkage to differing versions of the same library we now make
`brew linkage --test` verify that we don't have two versions of the
same library linked at the same time.
This will be considerably more permissive whilst checking the actual
problem that we're worried about. | Library/Homebrew/linkage_checker.rb | @@ -19,6 +19,7 @@ def initialize(keg, formula = nil, cache_db:, rebuild_cache: false)
@indirect_deps = []
@undeclared_deps = []
@unnecessary_deps = []
+ @version_conflict_deps = []
check_dylibs(rebuild_cache: rebuild_cache)
end
@@ -50,11 +51,14 @@ def display_reverse_output
def display_test_output(puts_output: true)
display_items "Missing libraries", @broken_dylibs, puts_output: puts_output
display_items "Broken dependencies", @broken_deps, puts_output: puts_output
+ display_items "Conflicting libraries", @version_conflict_deps, puts_output: puts_output
puts "No broken library linkage" unless broken_library_linkage?
end
def broken_library_linkage?
- !@broken_dylibs.empty? || !@broken_deps.empty?
+ !@broken_dylibs.empty? ||
+ !@broken_deps.empty? ||
+ !@version_conflict_deps.empty?
end
private
@@ -127,16 +131,16 @@ def check_dylibs(rebuild_cache:)
end
if formula
- @indirect_deps, @undeclared_deps, @unnecessary_deps =
- check_undeclared_deps
+ @indirect_deps, @undeclared_deps, @unnecessary_deps,
+ @version_conflict_deps = check_formula_deps
end
return unless keg_files_dylibs_was_empty
store&.update!(keg_files_dylibs: keg_files_dylibs)
end
- def check_undeclared_deps
+ def check_formula_deps
filter_out = proc do |dep|
next true if dep.build?
next false unless dep.optional? || dep.recommended?
@@ -170,13 +174,25 @@ def check_undeclared_deps
unnecessary_deps = declared_deps_full_names.reject do |full_name|
next true if Formula[full_name].bin.directory?
name = full_name.split("/").last
- @brewed_dylibs.keys.map { |x| x.split("/").last }.include?(name)
+ @brewed_dylibs.keys.map { |l| l.split("/").last }.include?(name)
end
missing_deps = @broken_deps.values.flatten.map { |d| dylib_to_dep(d) }
unnecessary_deps -= missing_deps
- [indirect_deps, undeclared_deps, unnecessary_deps]
+ version_hash = {}
+ version_conflict_deps = Set.new
+ @brewed_dylibs.keys.each do |l|
+ name = l.split("/").last
+ unversioned_name, = name.split("@")
+ version_hash[unversioned_name] ||= Set.new
+ version_hash[unversioned_name] << name
+ next if version_hash[unversioned_name].length < 2
+ version_conflict_deps += version_hash[unversioned_name]
+ end
+
+ [indirect_deps, undeclared_deps,
+ unnecessary_deps, version_conflict_deps.to_a]
end
def sort_by_formula_full_name!(arr) | true |
Other | Homebrew | brew | dced0da7e9577329db39272897aee60b4328307e.json | docs/Maintainer-Guidelines: add lead maintainer guidelines. | docs/Maintainer-Guidelines.md | @@ -115,3 +115,10 @@ Maintainers have a variety of ways to communicate with each other:
All communication should ideally occur in public on GitHub. Where this is not possible or appropriate (e.g. a security disclosure, interpersonal issue between two maintainers, urgent breakage that needs to be resolved) this can move to maintainers' private group communication and, if necessary, 1:1 communication. Technical decisions should not happen in 1:1 communications but if they do (or did in the past) they must end up back as something linkable on GitHub. For example, if a technical decision was made a year ago on Slack and another maintainer/contributor/user asks about it on GitHub, that's a good chance to explain it to them and have something that can be linked to in the future.
This makes it easier for other maintainers, contributors and users to follow along with what we're doing (and, more importantly, why we're doing it) and means that decisions have a linkable URL.
+
+## Lead maintainer guidelines
+There should be one lead maintainer for Homebrew. This person should (sparingly) be the tiebreaker for decisions where a mutual consensus cannot be reached amongst other maintainers. They should also be seen as the product manager for Homebrew itself and ensuring that changes made to the entire Homebrew ecosystem are consistent and providing an increasingly positive experience for Homebrew's users.
+
+In the same way that Homebrew maintainers are expected to be spending more of their time reviewing and merging contributions from non-maintainer contributors than making their own contributions, the lead maintainer should be spending most of their time reviewing work from and mentoring other maintainers.
+
+Individual Homebrew repositories should not have formal lead maintainers (although those who do the most work will have the loudest voices). | false |
Other | Homebrew | brew | ad0f9d603f5b04cb0c4e9d75fab36f4118bff942.json | extract: localize DependencyCollector monkey-patches too | Library/Homebrew/dev-cmd/extract.rb | @@ -37,6 +37,20 @@ def with_monkey_patch
define_method(:method_missing) { |*| }
end
+ DependencyCollector.class_eval do
+ if method_defined?(:parse_symbol_spec)
+ alias_method :old_parse_symbol_spec, :parse_symbol_spec
+ end
+ define_method(:parse_symbol_spec) { |*| }
+ end
+
+ DependencyCollector::Compat.class_eval do
+ if method_defined?(:parse_string_spec)
+ alias_method :old_parse_string_spec, :parse_string_spec
+ end
+ define_method(:parse_string_spec) { |*| }
+ end
+
yield
ensure
BottleSpecification.class_eval do
@@ -59,18 +73,20 @@ def with_monkey_patch
undef :old_method_missing
end
end
-end
-
-class DependencyCollector
- def parse_symbol_spec(*); end
- module Compat
- def parse_string_spec(spec, tags)
- super
+ DependencyCollector.class_eval do
+ if method_defined?(:old_parse_symbol_spec)
+ alias_method :parse_symbol_spec, :old_parse_symbol_spec
+ undef :old_parse_symbol_spec
end
end
- prepend Compat
+ DependencyCollector::Compat.class_eval do
+ if method_defined?(:old_parse_string_spec)
+ alias_method :parse_string_spec, :old_parse_string_spec
+ undef :old_parse_string_spec
+ end
+ end
end
module Homebrew | false |
Other | Homebrew | brew | bd352bcf35fd45f811e5bd2dbe7f918124e591a2.json | extract: use localized monkey-patching
Instead of just blanketing over with monkey-patches like before,
set up monkey-patches as needed, and make sure to clean up after
we're done. | Library/Homebrew/dev-cmd/extract.rb | @@ -15,28 +15,49 @@
require "formulary"
require "tap"
-# rubocop:disable Style/MethodMissingSuper
-class BottleSpecification
- def method_missing(*); end
+def with_monkey_patch
+ BottleSpecification.class_eval do
+ if method_defined?(:method_missing)
+ alias_method :old_method_missing, :method_missing
+ end
+ define_method(:method_missing) { |*| }
+ end
- def respond_to_missing?(*)
- true
+ Module.class_eval do
+ if method_defined?(:method_missing)
+ alias_method :old_method_missing, :method_missing
+ end
+ define_method(:method_missing) { |*| }
end
-end
-class Module
- def method_missing(*); end
+ Resource.class_eval do
+ if method_defined?(:method_missing)
+ alias_method :old_method_missing, :method_missing
+ end
+ define_method(:method_missing) { |*| }
+ end
- def respond_to_missing?(*)
- true
+ yield
+ensure
+ BottleSpecification.class_eval do
+ if method_defined?(:old_method_missing)
+ alias_method :method_missing, :old_method_missing
+ undef :old_method_missing
+ end
end
-end
-class Resource
- def method_missing(*); end
+ Module.class_eval do
+ if method_defined?(:old_method_missing)
+ alias_method :method_missing, :old_method_missing
+ undef :old_method_missing
+ end
+ end
- def respond_to_missing?(*)
- true
+ Resource.class_eval do
+ if method_defined?(:old_method_missing)
+ alias_method :method_missing, :old_method_missing
+ undef :old_method_missing
+ end
end
end
@@ -52,7 +73,6 @@ def parse_string_spec(spec, tags)
prepend Compat
end
-# rubocop:enable Style/MethodMissingSuper
module Homebrew
module_function
@@ -135,6 +155,6 @@ def formula_at_revision(repo, name, file, rev)
contents = Git.last_revision_of_file(repo, file, before_commit: rev)
contents.gsub!("@url=", "url ")
contents.gsub!("require 'brewkit'", "require 'formula'")
- Formulary.from_contents(name, file, contents)
+ with_monkey_patch { Formulary.from_contents(name, file, contents) }
end
end | false |
Other | Homebrew | brew | a8563afc9e60abc749bff43177c768c0af69dab9.json | extract: add progress message when searching Git history
For the impatient ones out there. | Library/Homebrew/dev-cmd/extract.rb | @@ -78,6 +78,7 @@ def extract
file = repo/"Formula/#{name}.rb"
if args.version
+ ohai "Searching repository history"
version = args.version
rev = "HEAD"
test_formula = nil
@@ -99,6 +100,7 @@ def extract
version = Formulary.factory(file).version
result = File.read(file)
else
+ ohai "Searching repository history"
rev = Git.last_revision_commit_of_file(repo, file)
version = formula_at_revision(repo, name, file, rev).version
odie "Could not find #{name}! The formula or version may not have existed." if rev.empty? | false |
Other | Homebrew | brew | d4a2006f0404de6696876e0e252ebc707ce419ee.json | extract: add missing monkey-patch | Library/Homebrew/dev-cmd/extract.rb | @@ -32,6 +32,14 @@ def respond_to_missing?(*)
end
end
+class Resource
+ def method_missing(*); end
+
+ def respond_to_missing?(*)
+ true
+ end
+end
+
class DependencyCollector
def parse_symbol_spec(*); end
| false |
Other | Homebrew | brew | 0e080eba97095d0212c605390ec59df2d52d23b0.json | extract: simplify integration tests | Library/Homebrew/test/dev-cmd/extract_spec.rb | @@ -1,5 +1,5 @@
describe "brew extract", :integration_test do
- it "retrieves the most recent formula version without version argument" do
+ it "retrieves the specified version of formula, defaulting to most recent" do
path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
(path/"Formula").mkpath
target = Tap.from_path(path)
@@ -21,119 +21,6 @@
expect(path/"Formula/testball@0.2.rb").to exist
expect(Formulary.factory(path/"Formula/testball@0.2.rb").version).to be == "0.2"
- end
-
- it "does not overwrite existing files, except when running with --force" do
- path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
- (path/"Formula").mkpath
- target = Tap.from_path(path)
- core_tap = CoreTap.new
- core_tap.path.cd do
- system "git", "init"
- formula_file = setup_test_formula "testball"
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.1"
- contents = File.read(formula_file)
- contents.gsub!("testball-0.1", "testball-0.2")
- File.write(formula_file, contents)
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.2"
- end
- expect { brew "extract", "testball", target.name }
- .to be_a_success
-
- expect(path/"Formula/testball@0.2.rb").to exist
-
- expect { brew "extract", "testball", target.name }
- .to be_a_failure
-
- expect { brew "extract", "testball", target.name, "--force" }
- .to be_a_success
-
- expect { brew "extract", "testball", target.name, "--version=0.1" }
- .to be_a_success
-
- expect(path/"Formula/testball@0.2.rb").to exist
-
- expect { brew "extract", "testball", "--version=0.1", target.name }
- .to be_a_failure
-
- expect { brew "extract", "testball", target.name, "--version=0.1", "--force" }
- .to be_a_success
- end
-
- it "retrieves the specified formula version when given argument" do
- path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
- (path/"Formula").mkpath
- target = Tap.from_path(path)
- core_tap = CoreTap.new
- core_tap.path.cd do
- system "git", "init"
- formula_file = setup_test_formula "testball"
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.1"
- contents = File.read(formula_file)
- contents.gsub!("testball-0.1", "testball-0.2")
- File.write(formula_file, contents)
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.2"
- end
- expect { brew "extract", "testball", target.name, "--version=0.1" }
- .to be_a_success
-
- expect { brew "extract", "testball", target.name, "--version=0.1", "--force" }
- .to be_a_success
-
- expect(Formulary.factory(path/"Formula/testball@0.1.rb").version).to be == "0.1"
- end
-
- it "retrieves most recent deleted formula when no argument is given" do
- path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
- (path/"Formula").mkpath
- target = Tap.from_path(path)
- core_tap = CoreTap.new
- core_tap.path.cd do
- system "git", "init"
- formula_file = setup_test_formula "testball"
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.1"
- contents = File.read(formula_file)
- contents.gsub!("testball-0.1", "testball-0.2")
- File.write(formula_file, contents)
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.2"
- File.delete(formula_file)
- system "git", "add", "--all"
- system "git", "commit", "-m", "Remove testball"
- end
-
- expect { brew "extract", "testball", target.name }
- .to be_a_success
-
- expect(path/"Formula/testball@0.2.rb").to exist
-
- expect(Formulary.factory(path/"Formula/testball@0.2.rb").version).to be == "0.2"
- end
-
- it "retrieves old version of deleted formula when argument is given" do
- path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
- (path/"Formula").mkpath
- target = Tap.from_path(path)
- core_tap = CoreTap.new
- core_tap.path.cd do
- system "git", "init"
- formula_file = setup_test_formula "testball"
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.1"
- contents = File.read(formula_file)
- contents.gsub!("testball-0.1", "testball-0.2")
- File.write(formula_file, contents)
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.2"
- File.delete(formula_file)
- system "git", "add", "--all"
- system "git", "commit", "-m", "Remove testball"
- end
expect { brew "extract", "testball", target.name, "--version=0.1" }
.to be_a_success
@@ -142,94 +29,4 @@
expect(Formulary.factory(path/"Formula/testball@0.1.rb").version).to be == "0.1"
end
-
- it "retrieves old formulae that use outdated/missing blocks" do
- path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
- (path/"Formula").mkpath
- target = Tap.from_path(path)
- core_tap = CoreTap.new
- core_tap.path.cd do
- system "git", "init"
- contents = <<~EOF
- require 'brewkit'
- class Testball < Formula
- @url="file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz"
- @md5='80a8aa0c5a8310392abf3b69f0319204'
-
- def install
- prefix.install "bin"
- prefix.install "libexec"
- Dir.chdir "doc"
- end
- end
- EOF
- formula_file = core_tap.path/"Formula/testball.rb"
- File.write(formula_file, contents)
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.1"
- contents = File.read(formula_file)
- contents.gsub!("testball-0.1", "testball-0.2")
- File.write(formula_file, contents)
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.2"
- File.delete(formula_file)
- system "git", "add", "--all"
- system "git", "commit", "-m", "Remove testball"
- end
-
- expect { brew "extract", "testball", target.name, "--version=0.1" }
- .to be_a_success
-
- expect(path/"Formula/testball@0.1.rb").to exist
- end
-
- it "fails when formula does not exist" do
- path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
- (path/"Formula").mkpath
- target = Tap.from_path(path)
- core_tap = CoreTap.new
- core_tap.path.cd do
- system "git", "init"
- formula_file = setup_test_formula "testball"
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.1"
- contents = File.read(formula_file)
- contents.gsub!("testball-0.1", "testball-0.2")
- File.write(formula_file, contents)
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.2"
- File.delete(formula_file)
- system "git", "add", "--all"
- system "git", "commit", "-m", "Remove testball"
- end
- expect { brew "extract", "foo", target.name }
- .to be_a_failure
- expect(Dir.entries(path/"Formula").size).to be == 2
- end
-
- it "fails when formula does not have the specified version" do
- path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
- (path/"Formula").mkpath
- target = Tap.from_path(path)
- core_tap = CoreTap.new
- core_tap.path.cd do
- system "git", "init"
- formula_file = setup_test_formula "testball"
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.1"
- contents = File.read(formula_file)
- contents.gsub!("testball-0.1", "testball-0.2")
- File.write(formula_file, contents)
- system "git", "add", "--all"
- system "git", "commit", "-m", "testball 0.2"
- File.delete(formula_file)
- system "git", "add", "--all"
- system "git", "commit", "-m", "Remove testball"
- end
-
- expect { brew "extract", "testball", target.name, "--version=0.3" }
- .to be_a_failure
-
- expect(path/"Formula/testball@0.3.rb").not_to exist
- end
end | false |
Other | Homebrew | brew | a232e3a791ac97b3ac45ab9d6b34e5c65a49b943.json | extract: fix corner case
If the formula to be retrieved was just version-bumped in the most
recent commit (HEAD), we would've ended up grabbing the second-most
recent version.
Instead, if the file already exists in tree at the current commit,
just construct the formula from that to get the version (for naming
purposes) and copy the file outright to its new location. | Library/Homebrew/dev-cmd/extract.rb | @@ -16,10 +16,18 @@
class BottleSpecification
def method_missing(*); end
+
+ def respond_to_missing?(*)
+ true
+ end
end
class Module
def method_missing(*); end
+
+ def respond_to_missing?(*)
+ true
+ end
end
class DependencyCollector
@@ -75,6 +83,9 @@ def extract
end
odie "Could not find #{name}! The formula or version may not have existed." if test_formula.nil?
result = Git.last_revision_of_file(repo, file, before_commit: rev)
+ elsif File.exist?(file)
+ version = Formulary.factory(file).version
+ result = File.read(file)
else
rev = Git.last_revision_commit_of_file(repo, file)
version = formula_at_revision(repo, name, file, rev).version | false |
Other | Homebrew | brew | ae32922d0f50602cbdfa719d0ad58650210eea39.json | swap which and command -v | Library/Homebrew/shims/linux/super/make | @@ -16,7 +16,7 @@ then
else
SAVED_PATH="$PATH"
pathremove "$HOMEBREW_LIBRARY/Homebrew/shims/linux/super"
- export MAKE="$(which make)"
+ export MAKE="$(command -v make)"
export PATH="$SAVED_PATH"
fi
| false |
Other | Homebrew | brew | 26e1d17b4d5bce5f2377b6d7bafc1082f4650b19.json | dev-cmd/bottle: save local_filename to json | Library/Homebrew/dev-cmd/bottle.rb | @@ -392,6 +392,7 @@ def bottle_formula(f)
"tags" => {
tag => {
"filename" => filename.bintray,
+ "local_filename" => filename.to_s,
"sha256" => sha256,
},
}, | false |
Other | Homebrew | brew | 0552dcff62f23017457ad4d1c76f7c8936d2a40a.json | extract: accept tap as a non-flagged argument | Library/Homebrew/dev-cmd/extract.rb | @@ -1,8 +1,7 @@
-#: * `extract` [`--force`] <formula> `--tap=`<tap> [`--version=`<version>]:
+#: * `extract` [`--force`] <formula> <tap> [`--version=`<version>]:
#: Looks through repository history to find the <version> of <formula> and
#: creates a copy in <tap>/Formula/<formula>@<version>.rb. If the tap is
#: not installed yet, attempts to install/clone the tap before continuing.
-#: A tap must be passed through `--tap` in order for `extract` to work.
#:
#: If `--force` is passed, the file at the destination will be overwritten
#: if it already exists. Otherwise, existing files will be preserved. | false |
Other | Homebrew | brew | 875885dda69ee2040f28187d7ca5f53e9ffa5c33.json | Add a starter file for spec | Library/Homebrew/test/dev-cmd/extract_spec.rb | @@ -0,0 +1,13 @@
+describe "brew extract", :integration_test do
+ it "extracts the most recent formula version without version argument" do
+ path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo"
+ (path/"Formula").mkpath
+ target = Tap.from_path(path)
+ formula_file = setup_test_formula "foo"
+
+ expect { brew "extract", "foo", target.name }
+ .to be_a_success
+
+ expect(path/"Formula/foo@1.0.rb").to exist
+ end
+end | false |
Other | Homebrew | brew | 95abdf96624029d5319462ac1d54613795c5cce9.json | Use refinements instead of general monkey-patching | Library/Homebrew/dev-cmd/extract.rb | @@ -15,96 +15,67 @@
require "formulary"
require "tap"
-class BottleSpecification
- def method_missing(m, *_args, &_block)
- if [:sha1, :md5].include?(m)
- opoo "Formula has unknown or deprecated stanza: #{m}" if ARGV.debug?
- else
- super
+module ExtractExtensions
+ refine BottleSpecification do
+ def method_missing(m, *_args, &_block)
+ # no-op
end
end
-end
-class Module
- def method_missing(m, *_args, &_block)
- if [:sha1, :md5].include?(m)
- opoo "Formula has unknown or deprecated stanza: #{m}" if ARGV.debug?
- else
- super
+ refine Module do
+ def method_missing(m, *_args, &_block)
+ # no-op
end
end
-end
-class DependencyCollector
- def parse_symbol_spec(spec, tags)
- case spec
- when :x11 then X11Requirement.new(spec.to_s, tags)
- when :xcode then XcodeRequirement.new(tags)
- when :linux then LinuxRequirement.new(tags)
- when :macos then MacOSRequirement.new(tags)
- when :arch then ArchRequirement.new(tags)
- when :java then JavaRequirement.new(tags)
- when :osxfuse then OsxfuseRequirement.new(tags)
- when :tuntap then TuntapRequirement.new(tags)
- when :ld64 then ld64_dep_if_needed(tags)
- else
- opoo "Unsupported special dependency #{spec.inspect}" if ARGV.debug?
+ refine DependencyCollector do
+ def parse_symbol_spec(spec, tags)
+ case spec
+ when :x11 then X11Requirement.new(spec.to_s, tags)
+ when :xcode then XcodeRequirement.new(tags)
+ when :linux then LinuxRequirement.new(tags)
+ when :macos then MacOSRequirement.new(tags)
+ when :arch then ArchRequirement.new(tags)
+ when :java then JavaRequirement.new(tags)
+ when :osxfuse then OsxfuseRequirement.new(tags)
+ when :tuntap then TuntapRequirement.new(tags)
+ when :ld64 then ld64_dep_if_needed(tags)
+ else
+ # no-op
+ end
end
- end
- module Compat
def parse_string_spec(spec, tags)
opoo "'depends_on ... => :run' is disabled. There is no replacement." if tags.include?(:run) && ARGV.debug?
super
end
end
-
- prepend Compat
end
module Homebrew
+ using ExtractExtensions
module_function
def extract
Homebrew::CLI::Parser.parse do
- flag "--tap="
flag "--version="
switch :debug
switch :force
end
- # If no formula args are given, ask specifically for a formula to be specified
- raise FormulaUnspecifiedError if ARGV.named.empty?
-
- # If some other number of args are given, provide generic usage information
- raise UsageError if ARGV.named.length != 1
-
- odie "The tap to which the formula is extracted must be specified!" if args.tap.nil?
+ # Expect exactly two named arguments: formula and tap
+ raise UsageError if ARGV.named.length != 2
- begin
- formula = Formulary.factory(ARGV.named.first)
- name = formula.name
- repo = formula.path.parent.parent
- file = formula.path
- rescue FormulaUnavailableError => e
- opoo "'#{ARGV.named.first}' does not currently exist in the core tap" if ARGV.debug?
- core = Tap.fetch("homebrew/core")
- name = ARGV.named.first.downcase
- repo = core.path
- file = core.path.join("Formula", "#{name}.rb")
- end
-
- destination_tap = Tap.fetch(args.tap)
+ destination_tap = Tap.fetch(ARGV.named[1])
+ odie "Cannot extract formula to homebrew/core!" if destination_tap.core_tap?
destination_tap.install unless destination_tap.installed?
- odie "Cannot extract formula to homebrew/core!" if destination_tap.name == "homebrew/core"
+ core = CoreTap.instance
+ name = ARGV.named.first.downcase
+ repo = core.path
+ file = core.path/"Formula/#{name}.rb"
- if args.version.nil?
- rev = Git.last_revision_commit_of_file(repo, file)
- version = formula_at_revision(repo, name, file, rev).version
- odie "Could not find #{name}! The formula or version may not have existed." if rev.empty?
- result = Git.last_revision_of_file(repo, file)
- else
+ if args.version
version = args.version
rev = "HEAD"
test_formula = nil
@@ -121,14 +92,19 @@ def extract
end
odie "Could not find #{name}! The formula or version may not have existed." if test_formula.nil?
result = Git.last_revision_of_file(repo, file, before_commit: rev)
+ else
+ rev = Git.last_revision_commit_of_file(repo, file)
+ version = formula_at_revision(repo, name, file, rev).version
+ odie "Could not find #{name}! The formula or version may not have existed." if rev.empty?
+ result = Git.last_revision_of_file(repo, file)
end
# The class name has to be renamed to match the new filename, e.g. Foo version 1.2.3 becomes FooAT123 and resides in Foo@1.2.3.rb.
class_name = name.capitalize
versioned_name = Formulary.class_s("#{class_name}@#{version}")
result.gsub!("class #{class_name} < Formula", "class #{versioned_name} < Formula")
- path = destination_tap.path.join("Formula", "#{name}@#{version}.rb")
+ path = destination_tap.path/"Formula/#{name}@#{version}.rb"
if path.exist?
unless ARGV.force?
odie <<~EOS
@@ -146,7 +122,7 @@ def extract
# @private
def formula_at_revision(repo, name, file, rev)
- return nil if rev.empty?
+ return if rev.empty?
contents = Git.last_revision_of_file(repo, file, before_commit: rev)
Formulary.from_contents(name, file, contents)
end | false |
Other | Homebrew | brew | bd2ac70c0fb9442f6fa8195d9b8cf899dba66481.json | Fix style issues in extract command | Library/Homebrew/dev-cmd/extract.rb | @@ -19,19 +19,19 @@ module Homebrew
module_function
def extract
- Homebrew::CLI::Parser.parse do
+ Homebrew::CLI::Parser.parse do
switch "--stdout", description: "Output to stdout on terminal instead of file"
switch :debug
switch :force
- end
+ end
odie "Cannot use a tap and --stdout at the same time!" if ARGV.named.length == 3 && args.stdout?
raise UsageError unless (ARGV.named.length == 3 && !args.stdout?) || (ARGV.named.length == 2 && args.stdout?)
formula = Formulary.factory(ARGV.named.first)
version = ARGV.named[1]
destination_tap = Tap.fetch(ARGV.named[2]) unless args.stdout?
- destination_tap.install unless destination_tap.installed? unless args.stdout?
+ destination_tap.install unless destination_tap.installed? || args.stdout?
unless args.stdout?
path = Pathname.new("#{destination_tap.path}/Formula/#{formula}@#{version}.rb") | false |
Other | Homebrew | brew | 1dff2f141ca7398ade175d8a1da85df3fc561350.json | Add manpages/docs for extract command | docs/Manpage.md | @@ -790,6 +790,18 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
* `edit` `formula`:
Open `formula` in the editor.
+ * `extract` [`--force`] [`--stdout`] `formula` `version` [`tap`]:
+ Looks through repository history to find the `version` of `formula` and
+ creates a copy in `tap`/Formula/`formula`@`version`.rb. If the tap is
+ not installed yet, attempts to install/clone the tap before continuing.
+
+ If `--force` is passed, the file at the destination will be overwritten
+ if it already exists. Otherwise, existing files will be preserved.
+
+ If `--stdout` is passed, the file will be written to stdout on the
+ terminal instead of written to a file. A `tap` cannot be passed when
+ using `--stdout`.
+
* `formula` `formula`:
Display the path where `formula` is located.
| true |
Other | Homebrew | brew | 1dff2f141ca7398ade175d8a1da85df3fc561350.json | Add manpages/docs for extract command | manpages/brew.1 | @@ -727,6 +727,16 @@ Open all of Homebrew for editing\.
Open \fIformula\fR in the editor\.
.
.TP
+\fBextract\fR [\fB\-\-force\fR] [\fB\-\-stdout\fR] \fIformula\fR \fIversion\fR [\fItap\fR]
+Looks through repository history to find the \fIversion\fR of \fIformula\fR and creates a copy in \fItap\fR/Formula/\fIformula\fR@\fIversion\fR\.rb\. If the tap is not installed yet, attempts to install/clone the tap before continuing\.
+.
+.IP
+If \fB\-\-force\fR is passed, the file at the destination will be overwritten if it already exists\. Otherwise, existing files will be preserved\.
+.
+.IP
+If \fB\-\-stdout\fR is passed, the file will be written to stdout on the terminal instead of written to a file\. A \fItap\fR cannot be passed when using \fB\-\-stdout\fR\.
+.
+.TP
\fBformula\fR \fIformula\fR
Display the path where \fIformula\fR is located\.
. | true |
Other | Homebrew | brew | 48dcf1916928999776df36882a553f15a9f0ffe7.json | Ignore unparsable system languages. | Library/Homebrew/cask/lib/hbc/dsl.rb | @@ -138,7 +138,17 @@ def language_eval
raise CaskInvalidError.new(cask, "No default language specified.")
end
- MacOS.languages.map(&Locale.method(:parse)).each do |locale|
+ locales = MacOS.languages
+ .map do |language|
+ begin
+ Locale.parse(language)
+ rescue Locale::ParserError
+ nil
+ end
+ end
+ .compact
+
+ locales.each do |locale|
key = locale.detect(@language_blocks.keys)
next if key.nil? | false |
Other | Homebrew | brew | 5c90833f0a16e9326750959aec91d779b889ceca.json | Use JSON to marshal errors from children | Library/Homebrew/build.rb | @@ -11,6 +11,8 @@
require "debrew"
require "fcntl"
require "socket"
+require "json"
+require "json/add/core"
class Build
attr_reader :formula, :deps, :reqs
@@ -190,7 +192,17 @@ def fixopt(f)
build = Build.new(formula, options)
build.install
rescue Exception => e # rubocop:disable Lint/RescueException
- Marshal.dump(e, error_pipe)
+ error_hash = JSON.parse e.to_json
+
+ # Special case: We need to toss our build state into the error hash
+ # for proper analytics reporting and sensible error messages.
+ if e.is_a?(BuildError)
+ error_hash["cmd"] = e.cmd
+ error_hash["args"] = e.args
+ error_hash["env"] = e.env
+ end
+
+ error_pipe.write error_hash.to_json
error_pipe.close
exit! 1
end | true |
Other | Homebrew | brew | 5c90833f0a16e9326750959aec91d779b889ceca.json | Use JSON to marshal errors from children | Library/Homebrew/dev-cmd/test.rb | @@ -93,12 +93,14 @@ def test
exec(*args)
end
end
- rescue ::Test::Unit::AssertionFailedError => e
+ rescue ChildProcessError => e
ofail "#{f.full_name}: failed"
- puts e.message
- rescue Exception => e # rubocop:disable Lint/RescueException
- ofail "#{f.full_name}: failed"
- puts e, e.backtrace
+ case e.inner["json_class"]
+ when "Test::Unit::AssertionFailedError"
+ puts e.inner["m"]
+ else
+ puts e.inner["json_class"], e.backtrace
+ end
ensure
ENV.replace(env)
end | true |
Other | Homebrew | brew | 5c90833f0a16e9326750959aec91d779b889ceca.json | Use JSON to marshal errors from children | Library/Homebrew/exceptions.rb | @@ -352,14 +352,16 @@ def initialize(formula)
end
class BuildError < RuntimeError
- attr_reader :formula, :env
+ attr_reader :formula, :cmd, :args, :env
attr_accessor :options
def initialize(formula, cmd, args, env)
@formula = formula
+ @cmd = cmd
+ @args = args
@env = env
- args = args.map { |arg| arg.to_s.gsub " ", "\\ " }.join(" ")
- super "Failed executing: #{cmd} #{args}"
+ pretty_args = args.map { |arg| arg.to_s.gsub " ", "\\ " }.join(" ")
+ super "Failed executing: #{cmd} #{pretty_args}"
end
def issues
@@ -596,3 +598,20 @@ def initialize(bottle_path, formula_path)
EOS
end
end
+
+# Raised when a child process sends us an exception over its error pipe.
+class ChildProcessError < RuntimeError
+ attr_reader :inner
+
+ def initialize(inner)
+ @inner = inner
+
+ super <<~EOS
+ An exception occured within a build process:
+ #{inner["json_class"]}: #{inner["m"]}
+ EOS
+
+ # Clobber our real (but irrelevant) backtrace with that of the inner exception.
+ set_backtrace inner["b"]
+ end
+end | true |
Other | Homebrew | brew | 5c90833f0a16e9326750959aec91d779b889ceca.json | Use JSON to marshal errors from children | Library/Homebrew/formula_installer.rb | @@ -763,14 +763,25 @@ def build
raise "Empty installation"
end
rescue Exception => e # rubocop:disable Lint/RescueException
- e.options = display_options(formula) if e.is_a?(BuildError)
+ # If we've rescued a ChildProcessError and that ChildProcessError
+ # contains a BuildError, then we reconstruct the inner build error
+ # to make analytics happy.
+ if e.is_a?(ChildProcessError) && e.inner["json_class"] == "BuildError"
+ build_error = BuildError.new(formula, e["cmd"], e["args"], e["env"])
+ build_error.set_backtrace e.backtrace
+ build_error.options = display_options(formula)
+
+ e = build_error
+ end
+
ignore_interrupts do
# any exceptions must leave us with nothing installed
formula.update_head_version
formula.prefix.rmtree if formula.prefix.directory?
formula.rack.rmdir_if_possible
end
- raise
+
+ raise e
end
def link(keg) | true |
Other | Homebrew | brew | 5c90833f0a16e9326750959aec91d779b889ceca.json | Use JSON to marshal errors from children | Library/Homebrew/postinstall.rb | @@ -4,6 +4,7 @@
require "debrew"
require "fcntl"
require "socket"
+require "json/add/core"
begin
error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
@@ -15,7 +16,7 @@
formula.extend(Debrew::Formula) if ARGV.debug?
formula.run_post_install
rescue Exception => e # rubocop:disable Lint/RescueException
- Marshal.dump(e, error_pipe)
+ error_pipe.write e.to_json
error_pipe.close
exit! 1
end | true |
Other | Homebrew | brew | 5c90833f0a16e9326750959aec91d779b889ceca.json | Use JSON to marshal errors from children | Library/Homebrew/test.rb | @@ -7,6 +7,7 @@
require "formula_assertions"
require "fcntl"
require "socket"
+require "json/add/core"
TEST_TIMEOUT_SECONDS = 5 * 60
@@ -28,7 +29,7 @@
raise "test returned false" if formula.run_test == false
end
rescue Exception => e # rubocop:disable Lint/RescueException
- Marshal.dump(e, error_pipe)
+ error_pipe.write e.to_json
error_pipe.close
exit! 1
end | true |
Other | Homebrew | brew | 5c90833f0a16e9326750959aec91d779b889ceca.json | Use JSON to marshal errors from children | Library/Homebrew/utils/fork.rb | @@ -1,5 +1,7 @@
require "fcntl"
require "socket"
+require "json"
+require "json/add/core"
module Utils
def self.safe_fork(&_block)
@@ -15,7 +17,7 @@ def self.safe_fork(&_block)
write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
yield
rescue Exception => e # rubocop:disable Lint/RescueException
- Marshal.dump(e, write)
+ write.write e.to_json
write.close
exit!
else
@@ -36,7 +38,7 @@ def self.safe_fork(&_block)
data = read.read
read.close
Process.wait(pid) unless socket.nil?
- raise Marshal.load(data) unless data.nil? || data.empty? # rubocop:disable Security/MarshalLoad
+ raise ChildProcessError, JSON.parse(data) unless data.nil? || data.empty?
raise Interrupt if $CHILD_STATUS.exitstatus == 130
raise "Forked child process failed: #{$CHILD_STATUS}" unless $CHILD_STATUS.success?
end | true |
Other | Homebrew | brew | ca59377a90970a88b58aeda8cf74b8803931dcdc.json | audit: add autocorrect and tests for test checks | Library/Homebrew/rubocops/class_cop.rb | @@ -39,6 +39,17 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
end
end
+ def autocorrect(node)
+ lambda do |corrector|
+ case node.type
+ when :str, :dstr
+ corrector.replace(node.source_range, node.source.to_s.sub(%r{(/usr/local/(s?bin))}, '#{\2}'))
+ when :int
+ corrector.remove(range_with_surrounding_comma(range_with_surrounding_space(range: node.source_range, side: :left)))
+ end
+ end
+ end
+
def_node_search :test_calls, <<~EOS
(send nil? ${:system :shell_output :pipe_output} $...)
EOS | true |
Other | Homebrew | brew | ca59377a90970a88b58aeda8cf74b8803931dcdc.json | audit: add autocorrect and tests for test checks | Library/Homebrew/test/rubocops/class_cop_spec.rb | @@ -76,6 +76,31 @@ class Foo < Formula
end
RUBY
end
+
+ it "supports auto-correcting test calls" do
+ source = <<~RUBY
+ class Foo < Formula
+ url 'https://example.com/foo-1.0.tgz'
+
+ test do
+ shell_output("/usr/local/sbin/test", 0)
+ end
+ end
+ RUBY
+
+ corrected_source = <<~RUBY
+ class Foo < Formula
+ url 'https://example.com/foo-1.0.tgz'
+
+ test do
+ shell_output("\#{sbin}/test")
+ end
+ end
+ RUBY
+
+ new_source = autocorrect_source(source)
+ expect(new_source).to eq(corrected_source)
+ end
end
describe RuboCop::Cop::FormulaAuditStrict::Test do | true |
Other | Homebrew | brew | 5f981a8722487dd9ee127a59f4f0471fa35c3c4c.json | tests: add test for test calls audit cop | Library/Homebrew/test/rubocops/class_cop_spec.rb | @@ -48,6 +48,36 @@ class Foo < Formula
end
end
+describe RuboCop::Cop::FormulaAudit::TestCalls do
+ subject(:cop) { described_class.new }
+
+ it "reports an offense when /usr/local/bin is found in test calls" do
+ expect_offense(<<~RUBY)
+ class Foo < Formula
+ url 'https://example.com/foo-1.0.tgz'
+
+ test do
+ system "/usr/local/bin/test"
+ ^^^^^^^^^^^^^^^^^^^^^ use \#{bin} instead of /usr/local/bin in system
+ end
+ end
+ RUBY
+ end
+
+ it "reports an offense when passing 0 as the second parameter to shell_output" do
+ expect_offense(<<~RUBY)
+ class Foo < Formula
+ url 'https://example.com/foo-1.0.tgz'
+
+ test do
+ shell_output("\#{bin}/test", 0)
+ ^ Passing 0 to shell_output() is redundant
+ end
+ end
+ RUBY
+ end
+end
+
describe RuboCop::Cop::FormulaAuditStrict::Test do
subject(:cop) { described_class.new }
| false |
Other | Homebrew | brew | 77c242548eab3df72f4905ffb29b896073ee11d2.json | update variable name and msg string per comments | Library/Homebrew/cmd/update-report.rb | @@ -22,12 +22,12 @@ def update_report
HOMEBREW_REPOSITORY.cd do
analytics_message_displayed =
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsmessage").chuzzle
- cask_analytics_message_displayed =
+ caskanalyticsmessage =
Utils.popen_read("git", "config", "--local", "--get", "homebrew.cask.analyticsmessage").chuzzle
analytics_disabled =
Utils.popen_read("git", "config", "--local", "--get", "homebrew.analyticsdisabled").chuzzle
if analytics_message_displayed != "true" &&
- cask_analytics_message_displayed != "true" &&
+ caskanalyticsmessage != "true" &&
analytics_disabled != "true" &&
!ENV["HOMEBREW_NO_ANALYTICS"] &&
!ENV["HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT"]
@@ -37,7 +37,7 @@ def update_report
print "\a"
# Use an extra newline and bold to avoid this being missed.
- ohai "Homebrew and Homebrew Cask have enabled anonymous aggregate user behaviour analytics."
+ ohai "Homebrew (and Cask) have enabled anonymous aggregate user behaviour analytics."
puts <<~EOS
#{Tty.bold}Read the analytics documentation (and how to opt-out) here:
#{Formatter.url("https://docs.brew.sh/Analytics")}#{Tty.reset} | false |
Other | Homebrew | brew | 6701c207e0d30b16eb6cba24f9da5cb4edf91395.json | add anlytics to cask installs | Library/Homebrew/cask/lib/hbc/installer.rb | @@ -90,6 +90,8 @@ def install
install_artifacts
enable_accessibility_access
+ Utils::Analytics.report_event("cask_install", @cask.token)
+
puts summary
end
| false |
Other | Homebrew | brew | 421ba101b4c4596b9da51fc1238a4542b487847b.json | test/ENV: Fix prepend_path for Linuxbrew
This test fails on Ubuntu, because /usr/libexec does not exist. | Library/Homebrew/test/ENV_spec.rb | @@ -116,11 +116,11 @@
describe "#prepend_path" do
it "prepends to a path" do
- subject.prepend_path "FOO", "/usr/libexec"
- expect(subject["FOO"]).to eq("/usr/libexec")
+ subject.prepend_path "FOO", "/usr/local"
+ expect(subject["FOO"]).to eq("/usr/local")
subject.prepend_path "FOO", "/usr"
- expect(subject["FOO"]).to eq("/usr#{File::PATH_SEPARATOR}/usr/libexec")
+ expect(subject["FOO"]).to eq("/usr#{File::PATH_SEPARATOR}/usr/local")
end
end
| false |
Other | Homebrew | brew | a30eea6ab93a227c8f13f0e8445bc6c998dfea67.json | pkgconfig: update 10.14 sqlite version | Library/Homebrew/os/mac/pkgconfig/10.14/sqlite3.pc | @@ -5,7 +5,7 @@ includedir=${prefix}/include
Name: SQLite
Description: SQL database engine
-Version: 3.22.0
+Version: 3.24.0
Libs: -L${libdir} -lsqlite3
Libs.private:
Cflags: -I${includedir} | false |
Other | Homebrew | brew | 1cf2ea79cf1e0f32f6db5cc56614357db5ecfbbe.json | xcode: update expected versions for Mojave | Library/Homebrew/os/mac/xcode.rb | @@ -265,7 +265,7 @@ def latest_version
# on the older supported platform for that Xcode release, i.e there's no
# CLT package for 10.11 that contains the Clang version from Xcode 8.
case MacOS.version
- when "10.14" then "1000.10.38"
+ when "10.14" then "1000.10.43.1"
when "10.13" then "902.0.39.2"
when "10.12" then "900.0.39.2"
when "10.11" then "800.0.42.1"
@@ -278,6 +278,7 @@ def latest_version
def minimum_version
case MacOS.version
+ when "10.14" then "10.0.0"
when "10.13" then "9.0.0"
when "10.12" then "8.0.0"
else "1.0.0" | false |
Other | Homebrew | brew | 879f514e28a90c2a9d1791d6b9cd02d23e3462e6.json | test/unpack_strategy: Handle svn unzip unavailable
Skip those tests that require svn or unzip. | Library/Homebrew/test/spec_helper.rb | @@ -85,7 +85,11 @@
end
config.before(:each, :needs_svn) do
- skip "Requires subversion." unless which "svn"
+ skip "subversion not installed." unless which "svn"
+ end
+
+ config.before(:each, :needs_unzip) do
+ skip "unzip not installed." unless which("unzip")
end
config.around(:each) do |example| | true |
Other | Homebrew | brew | 879f514e28a90c2a9d1791d6b9cd02d23e3462e6.json | test/unpack_strategy: Handle svn unzip unavailable
Skip those tests that require svn or unzip. | Library/Homebrew/test/unpack_strategy/jar_spec.rb | @@ -1,6 +1,6 @@
require_relative "shared_examples"
-describe UnpackStrategy::Jar do
+describe UnpackStrategy::Jar, :needs_unzip do
let(:path) { TEST_FIXTURE_DIR/"test.jar" }
include_examples "UnpackStrategy::detect" | true |
Other | Homebrew | brew | 879f514e28a90c2a9d1791d6b9cd02d23e3462e6.json | test/unpack_strategy: Handle svn unzip unavailable
Skip those tests that require svn or unzip. | Library/Homebrew/test/unpack_strategy/subversion_spec.rb | @@ -1,6 +1,6 @@
require_relative "shared_examples"
-describe UnpackStrategy::Subversion do
+describe UnpackStrategy::Subversion, :needs_svn do
let(:repo) { mktmpdir }
let(:working_copy) { mktmpdir }
let(:path) { working_copy } | true |
Other | Homebrew | brew | 879f514e28a90c2a9d1791d6b9cd02d23e3462e6.json | test/unpack_strategy: Handle svn unzip unavailable
Skip those tests that require svn or unzip. | Library/Homebrew/test/unpack_strategy/zip_spec.rb | @@ -4,7 +4,10 @@
let(:path) { TEST_FIXTURE_DIR/"cask/MyFancyApp.zip" }
include_examples "UnpackStrategy::detect"
- include_examples "#extract", children: ["MyFancyApp"]
+
+ context "when unzip is available", :needs_unzip do
+ include_examples "#extract", children: ["MyFancyApp"]
+ end
context "when ZIP archive is corrupted" do
let(:path) { | true |
Other | Homebrew | brew | 78658e430259bc030389668d6f6aec9b8e1066b2.json | Add cask cleanup and per-formula cache cleanup. | Library/Homebrew/cask/lib/hbc/cask_loader.rb | @@ -1,3 +1,4 @@
+require "hbc/cask"
require "uri"
module Hbc | true |
Other | Homebrew | brew | 78658e430259bc030389668d6f6aec9b8e1066b2.json | Add cask cleanup and per-formula cache cleanup. | Library/Homebrew/cleanup.rb | @@ -3,6 +3,8 @@
require "hbc/cask_loader"
module CleanupRefinement
+ LATEST_CASK_DAYS = 7
+
refine Pathname do
def incomplete?
extname.end_with?(".incomplete")
@@ -23,7 +25,7 @@ def prune?(days)
def stale?(scrub = false)
return false unless file?
- stale_formula?(scrub)
+ stale_formula?(scrub) || stale_cask?(scrub)
end
private
@@ -35,13 +37,16 @@ def stale_formula?(scrub)
begin
Utils::Bottles.resolve_version(self)
rescue
- self.version
+ nil
end
- else
- self.version
end
+ version ||= basename.to_s[/\A.*--(.*?)#{Regexp.escape(extname)}/, 1]
+
return false unless version
+
+ version = Version.parse(version)
+
return false unless (name = basename.to_s[/\A(.*?)\-\-?(?:#{Regexp.escape(version)})/, 1])
formula = begin
@@ -62,6 +67,29 @@ def stale_formula?(scrub)
false
end
+
+ def stale_cask?(scrub)
+ return false unless name = basename.to_s[/\A(.*?)\-\-/, 1]
+
+ cask = begin
+ Hbc::CaskLoader.load(name)
+ rescue Hbc::CaskUnavailableError
+ return false
+ end
+
+ unless basename.to_s.match?(/\A#{Regexp.escape(name)}\-\-#{Regexp.escape(cask.version)}\b/)
+ return true
+ end
+
+ return true if scrub && !cask.versions.include?(cask.version)
+
+ if cask.version.latest?
+ # TODO: Replace with ActiveSupport's `.days.ago`.
+ return mtime < ((@time ||= Time.now) - LATEST_CASK_DAYS * 60 * 60 * 24)
+ end
+
+ false
+ end
end
end
@@ -114,19 +142,18 @@ def clean!
end
end
- def update_disk_cleanup_size(path_size)
- @disk_cleanup_size += path_size
- end
-
def unremovable_kegs
@unremovable_kegs ||= []
end
def cleanup_formula(formula)
formula.eligible_kegs_for_cleanup.each(&method(:cleanup_keg))
+ cleanup_cache(Pathname.glob(cache/"#{formula.name}--*"))
end
- def cleanup_cask(cask); end
+ def cleanup_cask(cask)
+ cleanup_cache(Pathname.glob(cache/"Cask/#{cask.token}--*"))
+ end
def cleanup_keg(keg)
cleanup_path(keg) { keg.uninstall }
@@ -144,9 +171,10 @@ def cleanup_logs
end
end
- def cleanup_cache
- return unless cache.directory?
- cache.children.each do |path|
+ def cleanup_cache(entries = nil)
+ entries ||= [cache, cache/"Cask"].select(&:directory?).flat_map(&:children)
+
+ entries.each do |path|
next cleanup_path(path) { path.unlink } if path.incomplete?
next cleanup_path(path) { FileUtils.rm_rf path } if path.nested_cache?
@@ -159,7 +187,7 @@ def cleanup_cache
next
end
- next cleanup_path(path) { path.unlink } if path.stale?(ARGV.switch?("s"))
+ next cleanup_path(path) { path.unlink } if path.stale?(scrub?)
end
end
@@ -173,7 +201,7 @@ def cleanup_path(path)
yield
end
- update_disk_cleanup_size(disk_usage)
+ @disk_cleanup_size += disk_usage
end
def cleanup_lockfiles | true |
Other | Homebrew | brew | 6302d622e3d190845cf5a7104c085aa8ae5903a5.json | add new gclient_cache folder to cleanup | Library/Homebrew/cleanup.rb | @@ -9,7 +9,7 @@ def incomplete?
end
def nested_cache?
- directory? && ["glide_home", "java_cache", "npm_cache"].include?(basename.to_s)
+ directory? && %w[glide_home java_cache npm_cache gclient_cache].include?(basename.to_s)
end
def prune?(days) | true |
Other | Homebrew | brew | 6302d622e3d190845cf5a7104c085aa8ae5903a5.json | add new gclient_cache folder to cleanup | Library/Homebrew/test/cleanup_spec.rb | @@ -197,6 +197,15 @@
expect(npm_cache).not_to exist
end
+ it "cleans up 'gclient_cache'" do
+ gclient_cache = (HOMEBREW_CACHE/"gclient_cache")
+ gclient_cache.mkpath
+
+ subject.cleanup_cache
+
+ expect(gclient_cache).not_to exist
+ end
+
it "cleans up all files and directories" do
git = (HOMEBREW_CACHE/"gist--git")
gist = (HOMEBREW_CACHE/"gist") | true |
Other | Homebrew | brew | dc527fccdc5a335375ca3f6475ea3ec06ba969d1.json | formula_installer: avoid cyclic dependency
Fixes:
==> Installing patchelf dependency: patchelf
==> Installing dependencies for patchelf: patchelf
==> Installing patchelf dependency: patchelf
==> Installing dependencies for patchelf: patchelf
==> Installing patchelf dependency: patchelf
==> Installing dependencies for patchelf: patchelf
... | Library/Homebrew/formula_installer.rb | @@ -502,7 +502,7 @@ def expand_dependencies(deps)
end
end
- if pour_bottle
+ if pour_bottle && !Keg.relocation_formulae.include?(formula.name)
bottle_deps = Keg.relocation_formulae
.map { |formula| Dependency.new(formula) }
.reject do |dep| | false |
Other | Homebrew | brew | a20198cb894f242e5bae756c092b40e72cae8b64.json | MacOS: add sdk_path_if_needed tests | Library/Homebrew/test/os/mac_spec.rb | @@ -19,4 +19,44 @@
expect { Locale.parse(subject.language) }.not_to raise_error
end
end
+
+ describe "::sdk_path_if_needed" do
+ it "calls sdk_path on Xcode-only systems" do
+ allow(OS::Mac::Xcode).to receive(:installed?) { true }
+ allow(OS::Mac::CLT).to receive(:installed?) { false }
+ expect(OS::Mac).to receive(:sdk_path)
+ OS::Mac.sdk_path_if_needed
+ end
+
+ it "does not call sdk_path on Xcode-and-CLT systems with system headers" do
+ allow(OS::Mac::Xcode).to receive(:installed?) { true }
+ allow(OS::Mac::CLT).to receive(:installed?) { true }
+ allow(OS::Mac::CLT).to receive(:separate_header_package?) { false }
+ expect(OS::Mac).not_to receive(:sdk_path)
+ OS::Mac.sdk_path_if_needed
+ end
+
+ it "does not call sdk_path on CLT-only systems with no CLT SDK" do
+ allow(OS::Mac::Xcode).to receive(:installed?) { false }
+ allow(OS::Mac::CLT).to receive(:installed?) { true }
+ expect(OS::Mac).not_to receive(:sdk_path)
+ OS::Mac.sdk_path_if_needed
+ end
+
+ it "does not call sdk_path on CLT-only systems with a CLT SDK if the system provides headers" do
+ allow(OS::Mac::Xcode).to receive(:installed?) { false }
+ allow(OS::Mac::CLT).to receive(:installed?) { true }
+ allow(OS::Mac::CLT).to receive(:separate_header_package?) { false }
+ expect(OS::Mac).not_to receive(:sdk_path)
+ OS::Mac.sdk_path_if_needed
+ end
+
+ it "calls sdk_path on CLT-only systems with a CLT SDK if the system does not provide headers" do
+ allow(OS::Mac::Xcode).to receive(:installed?) { false }
+ allow(OS::Mac::CLT).to receive(:installed?) { true }
+ allow(OS::Mac::CLT).to receive(:separate_header_package?) { true }
+ expect(OS::Mac).to receive(:sdk_path)
+ OS::Mac.sdk_path_if_needed
+ end
+ end
end | false |
Other | Homebrew | brew | eea18a5cb10c9fa51086fd26843d3b47e2425f5b.json | MacOS: update sdk_path_if_needed logic | Library/Homebrew/os/mac.rb | @@ -101,7 +101,19 @@ def sdk_path(v = nil)
end
def sdk_path_if_needed(v = nil)
- return if !MacOS::Xcode.installed? && MacOS::CLT.separate_header_package?
+ # Prefer Xcode SDK when both Xcode and the CLT are installed.
+ # Expected results:
+ # 1. On Xcode-only systems, return the Xcode SDK.
+ # 2. On Xcode-and-CLT systems where headers are provided by the system, return nil.
+ # 3. On CLT-only systems with no CLT SDK, return nil.
+ # 4. On CLT-only systems with a CLT SDK, where headers are provided by the system, return nil.
+ # 5. On CLT-only systems with a CLT SDK, where headers are not provided by the system, return the CLT SDK.
+
+ # If there's no CLT SDK, return early
+ return if MacOS::CLT.installed? && !MacOS::CLT.provides_sdk?
+ # If the CLT is installed and provides headers, return early
+ return if MacOS::CLT.installed? && !MacOS::CLT.separate_header_package?
+
sdk_path(v)
end
| false |
Other | Homebrew | brew | e00720e8729bb5f5d8273bfb75e070e1028daed3.json | MacOS.sdk_path: prefer Xcode if installed | Library/Homebrew/os/mac.rb | @@ -85,7 +85,7 @@ def active_developer_dir
# specifically been requested according to the rules above.
def sdk(v = nil)
- @locator ||= if Xcode.without_clt?
+ @locator ||= if Xcode.installed?
XcodeSDKLocator.new
else
CLTSDKLocator.new | false |
Other | Homebrew | brew | 0cd84274053d88f70e1244a21ede906dfa3bfda1.json | Diagnostic: remove need for headers on 10.14 | Library/Homebrew/extend/os/mac/diagnostic.rb | @@ -20,7 +20,6 @@ def fatal_development_tools_checks
check_xcode_minimum_version
check_clt_minimum_version
check_if_xcode_needs_clt_installed
- check_if_clt_needs_headers_installed
].freeze
end
@@ -138,17 +137,6 @@ def check_if_xcode_needs_clt_installed
EOS
end
- def check_if_clt_needs_headers_installed
- return unless MacOS::CLT.separate_header_package?
- return if MacOS::CLT.headers_installed?
-
- <<~EOS
- The Command Line Tools header package must be installed on #{MacOS.version.pretty_name}.
- The installer is located at:
- #{MacOS::CLT::HEADER_PKG_PATH.sub(":macos_version", MacOS.version)}
- EOS
- end
-
def check_for_other_package_managers
ponk = MacOS.macports_or_fink
return if ponk.empty? | true |
Other | Homebrew | brew | 0cd84274053d88f70e1244a21ede906dfa3bfda1.json | Diagnostic: remove need for headers on 10.14 | Library/Homebrew/test/os/mac/diagnostic_spec.rb | @@ -32,19 +32,6 @@
.to match("Xcode alone is not sufficient on El Capitan")
end
- specify "#check_if_clt_needs_headers_installed" do
- allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.14"))
- allow(MacOS::CLT).to receive(:installed?).and_return(true)
- allow(MacOS::CLT).to receive(:headers_installed?).and_return(false)
-
- expect(subject.check_if_clt_needs_headers_installed)
- .to match("The Command Line Tools header package must be installed on Mojave.")
-
- allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.13"))
- expect(subject.check_if_clt_needs_headers_installed)
- .to be_nil
- end
-
specify "#check_homebrew_prefix" do
# the integration tests are run in a special prefix
expect(subject.check_homebrew_prefix) | true |
Other | Homebrew | brew | 03b93da2969914193a16b52b273f4b0fb1850c82.json | Use option parser for `brew cleanup`. | Library/Homebrew/cleanup.rb | @@ -1,5 +1,6 @@
require "utils/bottles"
require "formula"
+require "hbc/cask_loader"
module CleanupRefinement
refine Pathname do
@@ -67,22 +68,50 @@ def stale_formula?(scrub)
using CleanupRefinement
module Homebrew
- module Cleanup
- @disk_cleanup_size = 0
-
- class << self
- attr_reader :disk_cleanup_size
- end
+ class Cleanup
+ extend Predicable
+
+ attr_predicate :dry_run?, :scrub?
+ attr_reader :args, :days, :cache
+ attr_reader :disk_cleanup_size
+
+ def initialize(*args, dry_run: false, scrub: false, days: nil, cache: HOMEBREW_CACHE)
+ @disk_cleanup_size = 0
+ @args = args
+ @dry_run = dry_run
+ @scrub = scrub
+ @days = days
+ @cache = cache
+ end
+
+ def clean!
+ if args.empty?
+ Formula.installed.each do |formula|
+ cleanup_formula(formula)
+ end
+ cleanup_cache
+ cleanup_logs
+ return if dry_run?
+ cleanup_lockfiles
+ rm_ds_store
+ else
+ args.each do |arg|
+ formula = begin
+ Formula[arg]
+ rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
+ nil
+ end
- module_function
+ cask = begin
+ Hbc::CaskLoader.load(arg)
+ rescue Hbc::CaskUnavailableError
+ nil
+ end
- def cleanup
- cleanup_cellar
- cleanup_cache
- cleanup_logs
- return if ARGV.dry_run?
- cleanup_lockfiles
- rm_ds_store
+ cleanup_formula(formula) if formula
+ cleanup_cask(cask) if cask
+ end
+ end
end
def update_disk_cleanup_size(path_size)
@@ -93,14 +122,12 @@ def unremovable_kegs
@unremovable_kegs ||= []
end
- def cleanup_cellar(formulae = Formula.installed)
- formulae.each(&method(:cleanup_formula))
- end
-
def cleanup_formula(formula)
formula.eligible_kegs_for_cleanup.each(&method(:cleanup_keg))
end
+ def cleanup_cask(cask); end
+
def cleanup_keg(keg)
cleanup_path(keg) { keg.uninstall }
rescue Errno::EACCES => e
@@ -113,17 +140,17 @@ def cleanup_keg(keg)
def cleanup_logs
return unless HOMEBREW_LOGS.directory?
HOMEBREW_LOGS.subdirs.each do |dir|
- cleanup_path(dir) { dir.rmtree } if dir.prune?(ARGV.value("prune")&.to_i || DEFAULT_LOG_DAYS)
+ cleanup_path(dir) { dir.rmtree } if dir.prune?(days || DEFAULT_LOG_DAYS)
end
end
- def cleanup_cache(cache = HOMEBREW_CACHE)
+ def cleanup_cache
return unless cache.directory?
cache.children.each do |path|
next cleanup_path(path) { path.unlink } if path.incomplete?
next cleanup_path(path) { FileUtils.rm_rf path } if path.nested_cache?
- if path.prune?(ARGV.value("prune")&.to_i)
+ if path.prune?(days)
if path.file?
cleanup_path(path) { path.unlink }
elsif path.directory? && path.to_s.include?("--")
@@ -139,7 +166,7 @@ def cleanup_cache(cache = HOMEBREW_CACHE)
def cleanup_path(path)
disk_usage = path.disk_usage
- if ARGV.dry_run?
+ if dry_run?
puts "Would remove: #{path} (#{path.abv})"
else
puts "Removing: #{path}... (#{path.abv})" | true |
Other | Homebrew | brew | 03b93da2969914193a16b52b273f4b0fb1850c82.json | Use option parser for `brew cleanup`. | Library/Homebrew/cmd/cleanup.rb | @@ -12,34 +12,36 @@
#: deleted. If you want to delete those too: `rm -rf $(brew --cache)`
require "cleanup"
+require "cli_parser"
module Homebrew
module_function
def cleanup
- if ARGV.named.empty?
- Cleanup.cleanup
- else
- Cleanup.cleanup_cellar(ARGV.resolved_formulae)
+ CLI::Parser.parse do
+ switch "-n", "--dry-run"
+ switch "-s"
+ flag "--prune="
end
- report_disk_usage unless Cleanup.disk_cleanup_size.zero?
- report_unremovable_kegs unless Cleanup.unremovable_kegs.empty?
- end
+ cleanup = Cleanup.new(*args.remaining, dry_run: args.dry_run?, scrub: args.s?, days: args.prune&.to_i)
+
+ cleanup.clean!
- def report_disk_usage
- disk_space = disk_usage_readable(Cleanup.disk_cleanup_size)
- if ARGV.dry_run?
- ohai "This operation would free approximately #{disk_space} of disk space."
- else
- ohai "This operation has freed approximately #{disk_space} of disk space."
+ unless cleanup.disk_cleanup_size.zero?
+ disk_space = disk_usage_readable(cleanup.disk_cleanup_size)
+ if args.dry_run?
+ ohai "This operation would free approximately #{disk_space} of disk space."
+ else
+ ohai "This operation has freed approximately #{disk_space} of disk space."
+ end
end
- end
- def report_unremovable_kegs
+ return if cleanup.unremovable_kegs.empty?
+
ofail <<~EOS
Could not cleanup old kegs! Fix your permissions on:
- #{Cleanup.unremovable_kegs.join "\n "}
+ #{cleanup.unremovable_kegs.join "\n "}
EOS
end
end | true |
Other | Homebrew | brew | 03b93da2969914193a16b52b273f4b0fb1850c82.json | Use option parser for `brew cleanup`. | Library/Homebrew/cmd/update-report.rb | @@ -147,10 +147,6 @@ def migrate_legacy_cache_if_necessary
return unless legacy_cache.writable_real?
FileUtils.touch migration_attempted_file
- # Cleanup to avoid copying files unnecessarily
- ohai "Cleaning up #{legacy_cache}..."
- Cleanup.cleanup_cache legacy_cache
-
# This directory could have been compromised if it's world-writable/
# a symlink/owned by another user so don't copy files in those cases.
world_writable = legacy_cache.stat.mode & 0777 == 0777 | true |
Other | Homebrew | brew | 03b93da2969914193a16b52b273f4b0fb1850c82.json | Use option parser for `brew cleanup`. | Library/Homebrew/cmd/upgrade.rb | @@ -98,7 +98,7 @@ def upgrade
upgrade_formula(f)
next if !ARGV.include?("--cleanup") && !ENV["HOMEBREW_UPGRADE_CLEANUP"]
next unless f.installed?
- Homebrew::Cleanup.cleanup_formula f
+ Cleanup.new.cleanup_formula(f)
rescue UnsatisfiedRequirements => e
Homebrew.failed = true
onoe "#{f}: #{e}" | true |
Other | Homebrew | brew | 03b93da2969914193a16b52b273f4b0fb1850c82.json | Use option parser for `brew cleanup`. | Library/Homebrew/test/cleanup_spec.rb | @@ -43,16 +43,14 @@
describe "::cleanup" do
it "removes .DS_Store and lock files" do
- described_class.cleanup
+ subject.clean!
expect(ds_store).not_to exist
expect(lock_file).not_to exist
end
- it "doesn't remove anything if `--dry-run` is specified" do
- ARGV << "--dry-run"
-
- described_class.cleanup
+ it "doesn't remove anything if `dry_run` is true" do
+ described_class.new(dry_run: true).clean!
expect(ds_store).to exist
expect(lock_file).to exist
@@ -61,18 +59,16 @@
it "doesn't remove the lock file if it is locked" do
lock_file.open(File::RDWR | File::CREAT).flock(File::LOCK_EX | File::LOCK_NB)
- described_class.cleanup
+ subject.clean!
expect(lock_file).to exist
end
context "when it can't remove a keg" do
let(:f1) { Class.new(Testball) { version "0.1" }.new }
let(:f2) { Class.new(Testball) { version "0.2" }.new }
- let(:unremovable_kegs) { [] }
before do
- described_class.instance_variable_set(:@unremovable_kegs, [])
[f1, f2].each do |f|
f.brew do
f.install
@@ -87,13 +83,13 @@
end
it "doesn't remove any kegs" do
- described_class.cleanup_formula f2
+ subject.cleanup_formula f2
expect(f1.installed_kegs.size).to eq(2)
end
it "lists the unremovable kegs" do
- described_class.cleanup_formula f2
- expect(described_class.unremovable_kegs).to contain_exactly(f1.installed_kegs[0])
+ subject.cleanup_formula f2
+ expect(subject.unremovable_kegs).to contain_exactly(f1.installed_kegs[0])
end
end
end
@@ -131,7 +127,7 @@
expect(f3).to be_installed
expect(f4).to be_installed
- described_class.cleanup_formula f3
+ subject.cleanup_formula f3
expect(f1).not_to be_installed
expect(f2).not_to be_installed
@@ -146,21 +142,20 @@
path.mkpath
end
- it "cleans all logs if prune all" do
- ARGV << "--prune=all"
- described_class.cleanup_logs
+ it "cleans all logs if prune is 0" do
+ described_class.new(days: 0).cleanup_logs
expect(path).not_to exist
end
it "cleans up logs if older than 14 days" do
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 15 * 60 * 60 * 24)
- described_class.cleanup_logs
+ subject.cleanup_logs
expect(path).not_to exist
end
it "does not clean up logs less than 14 days old" do
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 2 * 60 * 60 * 24)
- described_class.cleanup_logs
+ subject.cleanup_logs
expect(path).to exist
end
end
@@ -170,7 +165,7 @@
incomplete = (HOMEBREW_CACHE/"something.incomplete")
incomplete.mkpath
- described_class.cleanup_cache
+ subject.cleanup_cache
expect(incomplete).not_to exist
end
@@ -179,7 +174,7 @@
glide_home = (HOMEBREW_CACHE/"glide_home")
glide_home.mkpath
- described_class.cleanup_cache
+ subject.cleanup_cache
expect(glide_home).not_to exist
end
@@ -188,7 +183,7 @@
java_cache = (HOMEBREW_CACHE/"java_cache")
java_cache.mkpath
- described_class.cleanup_cache
+ subject.cleanup_cache
expect(java_cache).not_to exist
end
@@ -197,7 +192,7 @@
npm_cache = (HOMEBREW_CACHE/"npm_cache")
npm_cache.mkpath
- described_class.cleanup_cache
+ subject.cleanup_cache
expect(npm_cache).not_to exist
end
@@ -211,9 +206,7 @@
gist.mkpath
FileUtils.touch svn
- allow(ARGV).to receive(:value).with("prune").and_return("all")
-
- described_class.cleanup_cache
+ described_class.new(days: 0).cleanup_cache
expect(git).not_to exist
expect(gist).to exist
@@ -223,27 +216,24 @@
it "does not clean up directories that are not VCS checkouts" do
git = (HOMEBREW_CACHE/"git")
git.mkpath
- allow(ARGV).to receive(:value).with("prune").and_return("all")
- described_class.cleanup_cache
+ described_class.new(days: 0).cleanup_cache
expect(git).to exist
end
it "cleans up VCS checkout directories with modified time < prune time" do
foo = (HOMEBREW_CACHE/"--foo")
foo.mkpath
- allow(ARGV).to receive(:value).with("prune").and_return("1")
allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 2 * 60 * 60 * 24)
- described_class.cleanup_cache
+ described_class.new(days: 1).cleanup_cache
expect(foo).not_to exist
end
it "does not clean up VCS checkout directories with modified time >= prune time" do
foo = (HOMEBREW_CACHE/"--foo")
foo.mkpath
- allow(ARGV).to receive(:value).with("prune").and_return("1")
- described_class.cleanup_cache
+ described_class.new(days: 1).cleanup_cache
expect(foo).to exist
end
@@ -260,20 +250,19 @@
it "cleans up file if outdated" do
allow(Utils::Bottles).to receive(:file_outdated?).with(any_args).and_return(true)
- described_class.cleanup_cache
+ subject.cleanup_cache
expect(bottle).not_to exist
expect(testball).not_to exist
end
- it "cleans up file if ARGV has -s and formula not installed" do
- ARGV << "-s"
- described_class.cleanup_cache
+ it "cleans up file if `scrub` is true and formula not installed" do
+ described_class.new(scrub: true).cleanup_cache
expect(bottle).not_to exist
expect(testball).not_to exist
end
it "cleans up file if stale" do
- described_class.cleanup_cache
+ subject.cleanup_cache
expect(bottle).not_to exist
expect(testball).not_to exist
end | true |
Other | Homebrew | brew | c1f4d0edb8c349e3f1fc2f4e2f11ed956e44542b.json | Remove trivial method. | Library/Homebrew/software_spec.rb | @@ -294,7 +294,7 @@ def initialize(formula, spec)
checksum, tag = spec.checksum_for(Utils::Bottles.tag)
filename = Filename.create(formula, tag, spec.rebuild)
- @resource.url(build_url(spec.root_url, filename.bintray),
+ @resource.url("#{spec.root_url}/#{filename.bintray}",
select_download_strategy(spec.root_url_specs))
@resource.version = formula.pkg_version
@resource.checksum = checksum
@@ -318,10 +318,6 @@ def stage
private
- def build_url(root_url, filename)
- "#{root_url}/#{filename}"
- end
-
def select_download_strategy(specs)
specs[:using] ||= DownloadStrategyDetector.detect(@spec.root_url)
specs | false |
Other | Homebrew | brew | bd5b41ed949ffcdf8cdb25d956bff0a4d6e9c5e2.json | Remove environment variables used by `hub`.
As of #3870, this is no longer needed. | Library/Homebrew/dev-cmd/bump-formula-pr.rb | @@ -78,14 +78,6 @@ def bump_formula_pr
# Use the user's browser, too.
ENV["BROWSER"] = ENV["HOMEBREW_BROWSER"]
- # Setup GitHub environment variables
- %w[GITHUB_USER GITHUB_PASSWORD GITHUB_TOKEN].each do |env|
- homebrew_env = ENV["HOMEBREW_#{env}"]
- next unless homebrew_env
- next if homebrew_env.empty?
- ENV[env] = homebrew_env
- end
-
formula = ARGV.formulae.first
if formula | true |
Other | Homebrew | brew | bd5b41ed949ffcdf8cdb25d956bff0a4d6e9c5e2.json | Remove environment variables used by `hub`.
As of #3870, this is no longer needed. | bin/brew | @@ -53,8 +53,7 @@ HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
# Whitelist and copy to HOMEBREW_* all variables previously mentioned in
# manpage or used elsewhere by Homebrew.
for VAR in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY BINTRAY_USER BINTRAY_KEY \
- BROWSER EDITOR GIT NO_COLOR PATH VISUAL \
- GITHUB_USER GITHUB_PASSWORD GITHUB_TOKEN
+ BROWSER EDITOR GIT NO_COLOR PATH VISUAL
do
# Skip if variable value is empty.
[[ -z "${!VAR}" ]] && continue | true |
Other | Homebrew | brew | ba410959c085ecc1d026167a452a6ca55951e50e.json | Add new maintainers
Also add some who were missing (sorry folks) and our Linux maintainers. | Library/Homebrew/dev-cmd/man.rb | @@ -74,6 +74,8 @@ def build_man_page
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:brew_maintainers] = readme.read[%r{(Homebrew/brew's other current maintainers .*\.)}, 1]
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
+ variables[:linux_maintainers] = readme.read[%r{(Homebrew/brew's Linux support \(and Linuxbrew\) maintainers are .*\.)}, 1]
+ .gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:core_maintainers] = readme.read[%r{(Homebrew/homebrew-core's other current maintainers .*\.)}, 1]
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:former_maintainers] = readme.read[/(Former maintainers .*\.)/, 1] | true |
Other | Homebrew | brew | ba410959c085ecc1d026167a452a6ca55951e50e.json | Add new maintainers
Also add some who were missing (sorry folks) and our Linux maintainers. | Library/Homebrew/manpages/brew.1.md.erb | @@ -311,6 +311,8 @@ Homebrew Documentation: <https://docs.brew.sh>
<%= brew_maintainers.concat("\n") %>
+<%= linux_maintainers.concat("\n") %>
+
<%= core_maintainers.concat("\n") %>
<%= former_maintainers.concat("\n") %> | true |
Other | Homebrew | brew | ba410959c085ecc1d026167a452a6ca55951e50e.json | Add new maintainers
Also add some who were missing (sorry folks) and our Linux maintainers. | README.md | @@ -42,11 +42,13 @@ Homebrew's project leadership committee is [Mike McQuaid](https://github.com/mik
Homebrew/homebrew-core's lead maintainer is [ilovezfs](https://github.com/ilovezfs).
-Homebrew/brew's other current maintainers are [ilovezfs](https://github.com/ilovezfs), [JCount](https://github.com/jcount), [Misty De Meo](https://github.com/mistydemeo), [Gautham Goli](https://github.com/GauthamGoli), [Markus Reiter](https://github.com/reitermarkus) and [William Woodruff](https://github.com/woodruffw).
+Homebrew/brew's other current maintainers are [Dominyk Tiller](https://github.com/DomT4), [Claudia](https://github.com/claui), [Michka Popoff](https://github.com/imichka), [Shaun Jackman](https://github.com/sjackman), [Chongyu Zhu](https://github.com/lembacon), [commitay](https://github.com/commitay), [Vitor Galvao](https://github.com/vitorgalvao), [ilovezfs](https://github.com/ilovezfs), [JCount](https://github.com/jcount), [Misty De Meo](https://github.com/mistydemeo), [Gautham Goli](https://github.com/GauthamGoli), [Markus Reiter](https://github.com/reitermarkus) and [William Woodruff](https://github.com/woodruffw).
-Homebrew/homebrew-core's other current maintainers are [FX Coudert](https://github.com/fxcoudert), [JCount](https://github.com/jcount), [Misty De Meo](https://github.com/mistydemeo) and [Tom Schoonjans](https://github.com/tschoonj).
+Homebrew/brew's Linux support (and Linuxbrew) maintainers are [Michka Popoff](https://github.com/imichka) and [Shaun Jackman](https://github.com/sjackman).
-Former maintainers with significant contributions include [Tim Smith](https://github.com/tdsmith), [Baptiste Fontaine](https://github.com/bfontaine), [Xu Cheng](https://github.com/xu-cheng), [Martin Afanasjew](https://github.com/UniqMartin), [Dominyk Tiller](https://github.com/DomT4), [Brett Koonce](https://github.com/asparagui), [Charlie Sharpsteen](https://github.com/Sharpie), [Jack Nagel](https://github.com/jacknagel), [Adam Vandenberg](https://github.com/adamv), [Andrew Janke](https://github.com/apjanke), [Alex Dunn](https://github.com/dunn), [neutric](https://github.com/neutric), [Tomasz Pajor](https://github.com/nijikon), [Uladzislau Shablinski](https://github.com/vladshablinsky), [Alyssa Ross](https://github.com/alyssais), and Homebrew's creator: [Max Howell](https://github.com/mxcl).
+Homebrew/homebrew-core's other current maintainers are [Dominyk Tiller](https://github.com/DomT4), [Claudia](https://github.com/claui), [Michka Popoff](https://github.com/imichka), [Shaun Jackman](https://github.com/sjackman), [Chongyu Zhu](https://github.com/lembacon), [commitay](https://github.com/commitay), [Izaak Beekman](https://github.com/zbeekman), [Sean Molenaar](https://github.com/SMillerDev), [Viktor Szakats](https://github.com/vszakats), [FX Coudert](https://github.com/fxcoudert), [JCount](https://github.com/jcount), [Misty De Meo](https://github.com/mistydemeo) and [Tom Schoonjans](https://github.com/tschoonj).
+
+Former maintainers with significant contributions include [Tim Smith](https://github.com/tdsmith), [Baptiste Fontaine](https://github.com/bfontaine), [Xu Cheng](https://github.com/xu-cheng), [Martin Afanasjew](https://github.com/UniqMartin), [Brett Koonce](https://github.com/asparagui), [Charlie Sharpsteen](https://github.com/Sharpie), [Jack Nagel](https://github.com/jacknagel), [Adam Vandenberg](https://github.com/adamv), [Andrew Janke](https://github.com/apjanke), [Alex Dunn](https://github.com/dunn), [neutric](https://github.com/neutric), [Tomasz Pajor](https://github.com/nijikon), [Uladzislau Shablinski](https://github.com/vladshablinsky), [Alyssa Ross](https://github.com/alyssais), and Homebrew's creator: [Max Howell](https://github.com/mxcl).
## Community
- [discourse.brew.sh (forum)](https://discourse.brew.sh) | true |
Other | Homebrew | brew | ba410959c085ecc1d026167a452a6ca55951e50e.json | Add new maintainers
Also add some who were missing (sorry folks) and our Linux maintainers. | docs/Manpage.md | @@ -1311,11 +1311,13 @@ Homebrew's project leadership committee is Mike McQuaid, ilovezfs, JCount, Misty
Homebrew/homebrew-core's lead maintainer is ilovezfs.
-Homebrew/brew's other current maintainers are ilovezfs, JCount, Misty De Meo, Gautham Goli, Markus Reiter and William Woodruff.
+Homebrew/brew's other current maintainers are Dominyk Tiller, Claudia, Michka Popoff, Shaun Jackman, Chongyu Zhu, commitay, Vitor Galvao, ilovezfs, JCount, Misty De Meo, Gautham Goli, Markus Reiter and William Woodruff.
-Homebrew/homebrew-core's other current maintainers are FX Coudert, JCount, Misty De Meo and Tom Schoonjans.
+Homebrew/brew's Linux support (and Linuxbrew) maintainers are Michka Popoff and Shaun Jackman.
-Former maintainers with significant contributions include Tim Smith, Baptiste Fontaine, Xu Cheng, Martin Afanasjew, Dominyk Tiller, Brett Koonce, Charlie Sharpsteen, Jack Nagel, Adam Vandenberg, Andrew Janke, Alex Dunn, neutric, Tomasz Pajor, Uladzislau Shablinski, Alyssa Ross, and Homebrew's creator: Max Howell.
+Homebrew/homebrew-core's other current maintainers are Dominyk Tiller, Claudia, Michka Popoff, Shaun Jackman, Chongyu Zhu, commitay, Izaak Beekman, Sean Molenaar, Viktor Szakats, FX Coudert, JCount, Misty De Meo and Tom Schoonjans.
+
+Former maintainers with significant contributions include Tim Smith, Baptiste Fontaine, Xu Cheng, Martin Afanasjew, Brett Koonce, Charlie Sharpsteen, Jack Nagel, Adam Vandenberg, Andrew Janke, Alex Dunn, neutric, Tomasz Pajor, Uladzislau Shablinski, Alyssa Ross, and Homebrew's creator: Max Howell.
## BUGS
| true |
Other | Homebrew | brew | ba410959c085ecc1d026167a452a6ca55951e50e.json | Add new maintainers
Also add some who were missing (sorry folks) and our Linux maintainers. | manpages/brew.1 | @@ -1278,13 +1278,16 @@ Homebrew\'s project leadership committee is Mike McQuaid, ilovezfs, JCount, Mist
Homebrew/homebrew\-core\'s lead maintainer is ilovezfs\.
.
.P
-Homebrew/brew\'s other current maintainers are ilovezfs, JCount, Misty De Meo, Gautham Goli, Markus Reiter and William Woodruff\.
+Homebrew/brew\'s other current maintainers are Dominyk Tiller, Claudia, Michka Popoff, Shaun Jackman, Chongyu Zhu, commitay, Vitor Galvao, ilovezfs, JCount, Misty De Meo, Gautham Goli, Markus Reiter and William Woodruff\.
.
.P
-Homebrew/homebrew\-core\'s other current maintainers are FX Coudert, JCount, Misty De Meo and Tom Schoonjans\.
+Homebrew/brew\'s Linux support (and Linuxbrew) maintainers are Michka Popoff and Shaun Jackman\.
.
.P
-Former maintainers with significant contributions include Tim Smith, Baptiste Fontaine, Xu Cheng, Martin Afanasjew, Dominyk Tiller, Brett Koonce, Charlie Sharpsteen, Jack Nagel, Adam Vandenberg, Andrew Janke, Alex Dunn, neutric, Tomasz Pajor, Uladzislau Shablinski, Alyssa Ross, and Homebrew\'s creator: Max Howell\.
+Homebrew/homebrew\-core\'s other current maintainers are Dominyk Tiller, Claudia, Michka Popoff, Shaun Jackman, Chongyu Zhu, commitay, Izaak Beekman, Sean Molenaar, Viktor Szakats, FX Coudert, JCount, Misty De Meo and Tom Schoonjans\.
+.
+.P
+Former maintainers with significant contributions include Tim Smith, Baptiste Fontaine, Xu Cheng, Martin Afanasjew, Brett Koonce, Charlie Sharpsteen, Jack Nagel, Adam Vandenberg, Andrew Janke, Alex Dunn, neutric, Tomasz Pajor, Uladzislau Shablinski, Alyssa Ross, and Homebrew\'s creator: Max Howell\.
.
.SH "BUGS"
See our issues on GitHub: | true |
Other | Homebrew | brew | 7d5f0df71d6f5cdaf2406fca862dfc878253c5bb.json | class_cop_spec: add tests for tighter test audit | Library/Homebrew/test/rubocops/class_cop_spec.rb | @@ -59,4 +59,29 @@ class Foo < Formula
end
RUBY
end
+
+ it "reports an offense when there is an empty test block" do
+ expect_offense(<<~RUBY)
+ class Foo < Formula
+ url 'https://example.com/foo-1.0.tgz'
+
+ test do
+ ^^^^^^^ `test do` should not be empty
+ end
+ end
+ RUBY
+ end
+
+ it "reports an offense when test is falsely true" do
+ expect_offense(<<~RUBY)
+ class Foo < Formula
+ url 'https://example.com/foo-1.0.tgz'
+
+ test do
+ ^^^^^^^ `test do` should contain a real test
+ true
+ end
+ end
+ RUBY
+ end
end | false |
Other | Homebrew | brew | 525300b9cdf5267065998aa5fff7ddebe7acd4ba.json | formula_desc_cop_spec: add whitespace tests | Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb | @@ -101,6 +101,26 @@ class Foo < Formula
RUBY
end
+ it "When the description starts with a leading space" do
+ expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
+ class Foo < Formula
+ url 'http://example.com/foo-1.0.tgz'
+ desc ' Description with a leading space'
+ ^ Description shouldn\'t have a leading space
+ end
+ RUBY
+ end
+
+ it "When the description ends with a trailing space" do
+ expect_offense(<<~RUBY, "/homebrew-core/Formula/foo.rb")
+ class Foo < Formula
+ url 'http://example.com/foo-1.0.tgz'
+ desc 'Description with a trailing space '
+ ^ Description shouldn\'t have a trailing space
+ end
+ RUBY
+ end
+
it "autocorrects all rules" do
source = <<~RUBY
class Foo < Formula | false |
Other | Homebrew | brew | 73194b460d047bec3a4d6fb31cf969a2b9e7aa77.json | formula_desc_cop: add unnecessary whitespace check | Library/Homebrew/rubocops/formula_desc_cop.rb | @@ -38,6 +38,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
module FormulaAuditStrict
# This cop audits `desc` in Formulae
#
+ # - Checks for leading/trailing whitespace in `desc`
# - Checks if `desc` begins with an article
# - Checks for correct usage of `command-line` in `desc`
# - Checks description starts with a capital letter
@@ -62,6 +63,16 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
desc = parameters(desc_call).first
+ # Check for leading whitespace.
+ if regex_match_group(desc, /^\s+/)
+ problem "Description shouldn't have a leading space"
+ end
+
+ # Check for trailing whitespace.
+ if regex_match_group(desc, /\s+$/)
+ problem "Description shouldn't have a trailing space"
+ end
+
# Check if command-line is wrongly used in formula's desc
if match = regex_match_group(desc, /(command ?line)/i)
c = match.to_s.chars.first
@@ -104,6 +115,8 @@ def autocorrect(node)
correction.gsub!(/^(['"]?)\s+/, "\\1")
correction.gsub!(/\s+(['"]?)$/, "\\1")
correction.gsub!(/\.(['"]?)$/, "\\1")
+ correction.gsub!(/^\s+/, "")
+ correction.gsub!(/\s+$/, "")
corrector.insert_before(node.source_range, correction)
corrector.remove(node.source_range)
end | false |
Other | Homebrew | brew | d5de9d585b74cc861fcbaf4d43f51da2f113fb27.json | Use normal download strategies for casks. | Library/Homebrew/cask/lib/hbc/download.rb | @@ -22,13 +22,9 @@ def perform
attr_accessor :downloaded_path
def downloader
- @downloader ||= case cask.url.using
- when :svn
- SubversionDownloadStrategy.new(cask)
- when :post
- CurlPostDownloadStrategy.new(cask)
- else
- CurlDownloadStrategy.new(cask)
+ @downloader ||= begin
+ strategy = DownloadStrategyDetector.detect(cask.url.to_s, cask.url.using)
+ strategy.new(cask.url.to_s, cask.token, cask.version, cache: Cache.path, **cask.url.specs)
end
end
@@ -37,7 +33,8 @@ def clear_cache
end
def fetch
- self.downloaded_path = downloader.fetch
+ downloader.fetch
+ @downloaded_path = downloader.cached_location
rescue StandardError => e
raise CaskError, "Download failed on Cask '#{cask}' with message: #{e}"
end | true |
Other | Homebrew | brew | d5de9d585b74cc861fcbaf4d43f51da2f113fb27.json | Use normal download strategies for casks. | Library/Homebrew/cask/lib/hbc/url.rb | @@ -6,19 +6,21 @@ class URL
:data
].freeze
- attr_reader :uri
+ attr_reader :uri, :specs
attr_reader(*ATTRIBUTES)
extend Forwardable
def_delegators :uri, :path, :scheme, :to_s
- def initialize(uri, options = {})
+ def initialize(uri, **options)
@uri = URI(uri)
@user_agent = :default
ATTRIBUTES.each do |attribute|
next unless options.key?(attribute)
instance_variable_set("@#{attribute}", options[attribute])
end
+
+ @specs = options
end
end | true |
Other | Homebrew | brew | d5de9d585b74cc861fcbaf4d43f51da2f113fb27.json | Use normal download strategies for casks. | Library/Homebrew/test/cask/cli/fetch_spec.rb | @@ -13,34 +13,44 @@
it_behaves_like "a command that requires a Cask token"
it_behaves_like "a command that handles invalid options"
- it "allows download the installer of a Cask" do
+ it "allows downloading the installer of a Cask" do
+ transmission_location = CurlDownloadStrategy.new(
+ local_transmission.url.to_s, local_transmission.token, local_transmission.version,
+ cache: Hbc::Cache.path, **local_transmission.url.specs
+ ).cached_location
+ caffeine_location = CurlDownloadStrategy.new(
+ local_caffeine.url.to_s, local_caffeine.token, local_caffeine.version,
+ cache: Hbc::Cache.path, **local_caffeine.url.specs
+ ).cached_location
+
+ expect(transmission_location).not_to exist
+ expect(caffeine_location).not_to exist
+
described_class.run("local-transmission", "local-caffeine")
- expect(Hbc::CurlDownloadStrategy.new(local_transmission).cached_location).to exist
- expect(Hbc::CurlDownloadStrategy.new(local_caffeine).cached_location).to exist
+
+ expect(transmission_location).to exist
+ expect(caffeine_location).to exist
end
it "prevents double fetch (without nuking existing installation)" do
- download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission)
+ cached_location = Hbc::Download.new(local_transmission).perform
- Hbc::Download.new(local_transmission).perform
- old_ctime = File.stat(download_stategy.cached_location).ctime
+ old_ctime = File.stat(cached_location).ctime
described_class.run("local-transmission")
- new_ctime = File.stat(download_stategy.cached_location).ctime
+ new_ctime = File.stat(cached_location).ctime
expect(old_ctime.to_i).to eq(new_ctime.to_i)
end
it "allows double fetch with --force" do
- Hbc::Download.new(local_transmission).perform
+ cached_location = Hbc::Download.new(local_transmission).perform
- download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission)
- old_ctime = File.stat(download_stategy.cached_location).ctime
+ old_ctime = File.stat(cached_location).ctime
sleep(1)
described_class.run("local-transmission", "--force")
- download_stategy = Hbc::CurlDownloadStrategy.new(local_transmission)
- new_ctime = File.stat(download_stategy.cached_location).ctime
+ new_ctime = File.stat(cached_location).ctime
expect(new_ctime.to_i).to be > old_ctime.to_i
end | true |
Other | Homebrew | brew | 888a7073bccc476fa5e14ca074c5d7ca0a0be5cf.json | Change migration to loop through formulae. | Library/Homebrew/cmd/update-report.rb | @@ -192,25 +192,41 @@ def migrate_legacy_cache_if_necessary
def migrate_cache_entries_to_double_dashes(initial_version)
return if initial_version > "1.7.1"
- HOMEBREW_CACHE.children.each do |child|
- next unless child.file?
+ Formula.each do |formula|
+ specs = [*formula.stable, *formula.devel, *formula.head]
+
+ resources = [*formula.bottle&.resource] + specs.flat_map do |spec|
+ [
+ spec,
+ *spec.resources.values,
+ *spec.patches.select(&:external?).map(&:resource),
+ ]
+ end
- next unless /^(?<prefix>[^\.]+[^\-])\-(?<suffix>[^\-].*)/ =~ child.basename.to_s
- target = HOMEBREW_CACHE/"#{prefix}--#{suffix}"
+ resources.each do |resource|
+ downloader = resource.downloader
- next if suffix.include?("--") && !suffix.start_with?("patch")
+ name = resource.download_name
+ version = resource.version
- if target.exist?
- begin
- FileUtils.rm_rf child
- rescue Errno::EACCES
- opoo "Could not remove #{child}, please do so manually."
- end
- else
- begin
- FileUtils.mv child, target
- rescue Errno::EACCES
- opoo "Could not move #{child} to #{target}, please do so manually."
+ new_location = downloader.cached_location
+ extname = new_location.extname
+ old_location = downloader.cached_location.dirname/"#{name}-#{version}#{extname}"
+
+ next unless old_location.file?
+
+ if new_location.exist?
+ begin
+ FileUtils.rm_rf old_location
+ rescue Errno::EACCES
+ opoo "Could not remove #{old_location}, please do so manually."
+ end
+ else
+ begin
+ FileUtils.mv old_location, new_location
+ rescue Errno::EACCES
+ opoo "Could not move #{old_location} to #{new_location}, please do so manually."
+ end
end
end
end | true |
Other | Homebrew | brew | 888a7073bccc476fa5e14ca074c5d7ca0a0be5cf.json | Change migration to loop through formulae. | Library/Homebrew/software_spec.rb | @@ -25,7 +25,7 @@ class SoftwareSpec
attr_reader :compiler_failures
def_delegators :@resource, :stage, :fetch, :verify_download_integrity, :source_modified_time
- def_delegators :@resource, :cached_download, :clear_cache
+ def_delegators :@resource, :download_name, :cached_download, :clear_cache
def_delegators :@resource, :checksum, :mirrors, :specs, :using
def_delegators :@resource, :version, :mirror, *Checksum::TYPES
def_delegators :@resource, :downloader | true |
Other | Homebrew | brew | 888a7073bccc476fa5e14ca074c5d7ca0a0be5cf.json | Change migration to loop through formulae. | Library/Homebrew/test/cmd/update-report_spec.rb | @@ -2,51 +2,45 @@
describe "brew update-report" do
describe "::migrate_cache_entries_to_double_dashes" do
- let(:legacy_cache_file) { HOMEBREW_CACHE/"foo-1.2.3.tar.gz" }
- let(:renamed_cache_file) { HOMEBREW_CACHE/"foo--1.2.3.tar.gz" }
+ let(:formula_name) { "foo" }
+ let(:f) {
+ formula formula_name do
+ url "https://example.com/foo-1.2.3.tar.gz"
+ version "1.2.3"
+ end
+ }
+ let(:old_cache_file) { HOMEBREW_CACHE/"#{formula_name}-1.2.3.tar.gz" }
+ let(:new_cache_file) { HOMEBREW_CACHE/"#{formula_name}--1.2.3.tar.gz" }
before(:each) do
- FileUtils.touch legacy_cache_file
+ FileUtils.touch old_cache_file
+ allow(Formula).to receive(:each).and_yield(f)
end
it "moves old files to use double dashes when upgrading from <= 1.7.1" do
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
- expect(legacy_cache_file).not_to exist
- expect(renamed_cache_file).to exist
+ expect(old_cache_file).not_to exist
+ expect(new_cache_file).to exist
end
context "when the formula name contains dashes" do
- let(:legacy_cache_file) { HOMEBREW_CACHE/"foo-bar-1.2.3.tar.gz" }
- let(:renamed_cache_file) { HOMEBREW_CACHE/"foo-bar--1.2.3.tar.gz" }
-
- it "does not introduce extra double dashes when called multiple times" do
- Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
- Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
-
- expect(legacy_cache_file).not_to exist
- expect(renamed_cache_file).to exist
- end
- end
-
- context "when the file is a patch and the formula name contains dashes" do
- let(:legacy_cache_file) { HOMEBREW_CACHE/"foo-bar-patch--1.2.3.tar.gz" }
- let(:renamed_cache_file) { HOMEBREW_CACHE/"foo-bar--patch--1.2.3.tar.gz" }
+ let(:formula_name) { "foo-bar" }
it "does not introduce extra double dashes when called multiple times" do
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
- expect(legacy_cache_file).not_to exist
- expect(renamed_cache_file).to exist
+ expect(old_cache_file).not_to exist
+ expect(new_cache_file).to exist
end
end
it "does not move files if upgrading from > 1.7.1" do
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.2"))
- expect(legacy_cache_file).to exist
- expect(renamed_cache_file).not_to exist
+ expect(old_cache_file).to exist
+ expect(new_cache_file).not_to exist
end
end
end | true |
Other | Homebrew | brew | 4a48297d1c0a5721371405091f89fffd484d776e.json | Fix cleanup for files with `--`. | Library/Homebrew/cleanup.rb | @@ -83,7 +83,7 @@ def cleanup_cache(cache = HOMEBREW_CACHE)
version = file.version
end
next unless version
- next unless (name = file.basename.to_s[/(.*)-(?:#{Regexp.escape(version)})/, 1])
+ next unless (name = file.basename.to_s[/\A(.*?)\-\-?(?:#{Regexp.escape(version)})/, 1])
next unless HOMEBREW_CELLAR.directory?
| true |
Other | Homebrew | brew | 4a48297d1c0a5721371405091f89fffd484d776e.json | Fix cleanup for files with `--`. | Library/Homebrew/test/cleanup_spec.rb | @@ -226,8 +226,8 @@
end
context "cleans old files in HOMEBREW_CACHE" do
- let(:bottle) { (HOMEBREW_CACHE/"testball-0.0.1.bottle.tar.gz") }
- let(:testball) { (HOMEBREW_CACHE/"testball-0.0.1") }
+ let(:bottle) { (HOMEBREW_CACHE/"testball--0.0.1.bottle.tar.gz") }
+ let(:testball) { (HOMEBREW_CACHE/"testball--0.0.1") }
before do
FileUtils.touch(bottle) | true |
Other | Homebrew | brew | dca5dc817617717ff7843ac969f23d83b73d079f.json | Add warnings for permission exceptions. | Library/Homebrew/cmd/update-report.rb | @@ -199,9 +199,17 @@ def migrate_cache_entries_to_double_dashes(initial_version)
target = HOMEBREW_CACHE/"#{prefix}--#{suffix}"
if target.exist?
- FileUtils.rm_rf child
+ begin
+ FileUtils.rm_rf child
+ rescue Errno::EACCES
+ opoo "Could not remove #{child}, please do so manually."
+ end
else
- FileUtils.mv child, target, force: true
+ begin
+ FileUtils.mv child, target
+ rescue Errno::EACCES
+ opoo "Could not move #{child} to #{target}, please do so manually."
+ end
end
end
end | false |
Other | Homebrew | brew | 4065c1742dbcfb1105827f89a0026fe8b4578da5.json | Add update migration for double dashes. | Library/Homebrew/cmd/update-report.rb | @@ -85,6 +85,7 @@ def update_report
end
migrate_legacy_cache_if_necessary
+ migrate_cache_entries_to_double_dashes
migrate_legacy_keg_symlinks_if_necessary
if !updated
@@ -183,6 +184,21 @@ def migrate_legacy_cache_if_necessary
end
end
+ def migrate_cache_entries_to_double_dashes
+ HOMEBREW_CACHE.children.each do |child|
+ next unless child.file?
+
+ next unless /^(?<prefix>[^\.]+[^\-])\-(?<suffix>[^\-].*)/ =~ child.basename.to_s
+ target = HOMEBREW_CACHE/"#{prefix}--#{suffix}"
+
+ if target.exist?
+ FileUtils.rm_rf child
+ else
+ FileUtils.mv child, target, force: true
+ end
+ end
+ end
+
def migrate_legacy_repository_if_necessary
return unless HOMEBREW_PREFIX.to_s == "/usr/local"
return unless HOMEBREW_REPOSITORY.to_s == "/usr/local" | false |
Other | Homebrew | brew | a42675f7d6c91017d930dfd427f6f73bf5b61753.json | docs/New-Maintainer-Checklist: update best practises.
We've made these recommendations to current maintainers to update the
documentation so we don't forget to ask new maintainers to do the same
when we invite more in future. | docs/New-Maintainer-Checklist.md | @@ -8,7 +8,7 @@ First, send them the invitation email:
```
The Homebrew team and I really appreciate your help on issues, pull requests and
-your contributions around $THEIR_CONTRIBUTIONS.
+your contributions to Homebrew.
We would like to invite you to have commit access and be a Homebrew maintainer.
If you agree to be a maintainer, you should spend a significant proportion of
@@ -17,9 +17,12 @@ issues that arise from your code in a timely fashion and reviewing user
contributions. You should also be making contributions to Homebrew every month
unless you are ill or on vacation (and please let another maintainer know if
that's the case so we're aware you won't be able to help while you are out).
-You will need to watch Homebrew/brew and/or Homebrew/homebrew-core. If you're
-no longer able to perform all of these tasks, please continue to contribute to
-Homebrew, but we will ask you to step down as a maintainer.
+
+You will need to watch Homebrew/brew and/or Homebrew/homebrew-core. Let us know
+which (or both) so we can grant you commit access appropriately.
+
+If you're no longer able to perform all of these tasks, please continue to
+contribute to Homebrew, but we will ask you to step down as a maintainer.
A few requests:
@@ -56,7 +59,9 @@ If they accept, follow a few steps to get them set up:
- Add them to the [Jenkins' GitHub Pull Request Builder admin list](https://jenkins.brew.sh/configure) to enable `@BrewTestBot test this please` for them
- Invite them to the [`homebrew-maintainers` private maintainers mailing list](https://lists.sfconservancy.org/mailman/admin/homebrew-maintainers/members/add)
- Invite them to the [`machomebrew` private maintainers Slack](https://machomebrew.slack.com/admin/invites) (and ensure they've read the [communication guidelines](Maintainer-Guidelines.md#communication))
-- Add them to [Homebrew's README](https://github.com/Homebrew/brew/edit/master/README.md)
+- Ask them to disable SMS as a 2FA device or fallback on their GitHub account in favour of using one of the other authentication methods.
+- Ask them to (regularly) review remove any unneeded [GitHub personal access tokens](https://github.com/settings/tokens)
+- Add them to [Homebrew/brew's README](https://github.com/Homebrew/brew/edit/master/README.md)
If they are also interested in doing system administration work:
@@ -69,7 +74,7 @@ If they want to consume raw anonymous aggregate analytics data (rather than use
Once they have been active maintainers for at least a year and had some activity on more than one Homebrew organisation repository (or one repository and helped with system administration work):
-- Homebrew's [Software Freedom Conservancy](https://sfconservancy.org) Project Leadership Committee can take a vote on whether to extend an offer to the maintainer to join the committee. If they accept, email their name, email and employer to homebrew@sfconservancy.org and make them [owners on the Homebrew GitHub organisation](https://github.com/orgs/Homebrew/people).
+- Homebrew's [Software Freedom Conservancy](https://sfconservancy.org) Project Leadership Committee can take a vote on whether to extend an offer to the maintainer to join the committee. If they accept, email their name, email and employer to homebrew@sfconservancy.org, make them [owners on the Homebrew GitHub organisation](https://github.com/orgs/Homebrew/people) and add them to the relevant section of the [Homebrew/brew's README](https://github.com/Homebrew/brew/edit/master/README.md).
If there are problems, ask them to step down as a maintainer and revoke their access to all of the above.
| false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.