Skip to content

Commit

Permalink
Merge pull request #18914 from Homebrew/scope-constants
Browse files Browse the repository at this point in the history
Namespace some top-level constants
  • Loading branch information
dduugg authored Dec 11, 2024
2 parents 563c2b1 + 9e3e1e1 commit 0bcb764
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
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 @@ class GitHubPackages
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 @@ def upload_bottle(user, token, skopeo, formula_full_name, bottle_hash, keep_old:

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))
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

0 comments on commit 0bcb764

Please sign in to comment.