Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace some top-level constants #18914

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Library/Homebrew/cask/artifact/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

require "cask/artifact/abstract_uninstall"

UPGRADE_REINSTALL_SKIP_DIRECTIVES = [:quit, :signal].freeze

module Cask
module Artifact
# Artifact corresponding to the `uninstall` stanza.
class Uninstall < AbstractUninstall
UPGRADE_REINSTALL_SKIP_DIRECTIVES = [:quit, :signal].freeze

def uninstall_phase(upgrade: false, reinstall: false, **options)
filtered_directives = ORDERED_DIRECTIVES.filter do |directive_sym|
next false if directive_sym == :rmdir
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/cask/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
require "utils/user"
require "open3"

BUG_REPORTS_URL = "https://github.com/Homebrew/homebrew-cask#reporting-bugs"

module Cask
# Helper functions for various cask operations.
module Utils
BUG_REPORTS_URL = "https://github.com/Homebrew/homebrew-cask#reporting-bugs"

def self.gain_permissions_mkpath(path, command: SystemCommand)
dir = path.ascend.find(&:directory?)
return if path == dir
Expand Down
6 changes: 2 additions & 4 deletions Library/Homebrew/github_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

require "utils/curl"
require "utils/gzip"
require "json"
require "zlib"
require "extend/hash/keys"
Expand All @@ -26,9 +27,6 @@
VALID_OCI_TAG_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$/
INVALID_OCI_TAG_CHARS_REGEX = /[^a-zA-Z0-9._-]/

GZIP_BUFFER_SIZE = 64 * 1024
private_constant :GZIP_BUFFER_SIZE

# Translate Homebrew tab.arch to OCI platform.architecture
TAB_ARCH_TO_PLATFORM_ARCHITECTURE = {
"arm64" => "arm64",
Expand Down Expand Up @@ -382,7 +380,7 @@

tar_sha256 = Digest::SHA256.new
Zlib::GzipReader.open(local_file) do |gz|
while (data = gz.read(GZIP_BUFFER_SIZE))
while (data = gz.read(Utils::Gzip::GZIP_BUFFER_SIZE))

Check warning on line 383 in Library/Homebrew/github_packages.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/github_packages.rb#L383

Added line #L383 was not covered by tests
tar_sha256 << data
end
end
Expand Down
7 changes: 4 additions & 3 deletions Library/Homebrew/manpages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
require "cli/parser"
require "erb"

SOURCE_PATH = (HOMEBREW_LIBRARY_PATH/"manpages").freeze
TARGET_MAN_PATH = (HOMEBREW_REPOSITORY/"manpages").freeze
TARGET_DOC_PATH = (HOMEBREW_REPOSITORY/"docs").freeze
module Homebrew
# Helper functions for generating homebrew manual.
module Manpages
Expand All @@ -25,6 +22,10 @@ module Manpages
keyword_init: true,
)

SOURCE_PATH = (HOMEBREW_LIBRARY_PATH/"manpages").freeze
TARGET_MAN_PATH = (HOMEBREW_REPOSITORY/"manpages").freeze
TARGET_DOC_PATH = (HOMEBREW_REPOSITORY/"docs").freeze

def self.regenerate_man_pages(quiet:)
require "kramdown"
require "manpages/parser/ronn"
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/utils/gzip.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# typed: strict
# frozen_string_literal: true

# Apple's gzip also uses zlib so use the same buffer size here.
# https://github.com/apple-oss-distributions/file_cmds/blob/file_cmds-400/gzip/gzip.c#L147
GZIP_BUFFER_SIZE = T.let(64 * 1024, Integer)

module Utils
# Helper functions for creating gzip files.
module Gzip
# Apple's gzip also uses zlib so use the same buffer size here.
# https://github.com/apple-oss-distributions/file_cmds/blob/file_cmds-400/gzip/gzip.c#L147
GZIP_BUFFER_SIZE = T.let(64 * 1024, Integer)

sig {
params(
path: T.any(String, Pathname),
Expand Down
Loading