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
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/upgrade.rb
@@ -89,6 +89,8 @@ def upgrade_args cask_options conflicts "--build-from-source", "--force-bottle" + + named_args [:installed_formula, :installed_cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/cmd/uses.rb
@@ -46,7 +46,8 @@ def uses_args description: "Include only casks." conflicts "--formula", "--cask" - min_named :formula + + named_args :formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/audit.rb
@@ -90,6 +90,8 @@ def audit_args conflicts "--display-cop-names", "--skip-style" conflicts "--display-cop-names", "--only-cops" conflicts "--display-cop-names", "--except-cops" + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/bottle.rb
@@ -86,7 +86,8 @@ def bottle_args description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default." conflicts "--no-rebuild", "--keep-old" - min_named 1 + + named_args :installed_formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/bump-cask-pr.rb
@@ -52,7 +52,8 @@ def bump_cask_pr_args conflicts "--dry-run", "--write" conflicts "--no-audit", "--online" - named 1 + + named_args :cask, number: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -79,7 +79,8 @@ def bump_formula_pr_args conflicts "--no-audit", "--strict" conflicts "--no-audit", "--online" conflicts "--url", "--tag" - max_named 1 + + named_args :formula, max: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/bump-revision.rb
@@ -23,7 +23,7 @@ def bump_revision_args flag "--message=", description: "Append <message> to the default commit message." - min_named :formula + named_args :formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/bump-unversioned-casks.rb
@@ -29,7 +29,7 @@ def self.bump_unversioned_casks_args flag "--state-file=", description: "File for caching state." - min_named 1 + named_args [:cask, :tap], min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/bump.rb
@@ -21,6 +21,8 @@ def bump_args description: "Limit number of package results returned." switch :verbose switch :debug + + named_args :formula end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/cat.rb
@@ -23,7 +23,7 @@ def cat_args description: "Treat all named arguments as casks." conflicts "--formula", "--cask" - named :formula_or_cask + named_args [:formula, :cask], number: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/command.rb
@@ -18,7 +18,7 @@ def command_args Display the path to the file being used when invoking `brew` <cmd>. EOS - min_named 1 + named_args :command, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/create.rb
@@ -69,7 +69,7 @@ def create_args conflicts "--cask", "--HEAD" conflicts "--cask", "--set-license" - named 1 + named_args number: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/dispatch-build-bottle.rb
@@ -28,7 +28,7 @@ def dispatch_build_bottle_args switch "--upload", description: "Upload built bottles to Bintray." - min_named :formula + named_args :formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/edit.rb
@@ -24,6 +24,8 @@ def edit_args switch "--cask", "--casks", description: "Treat all named arguments as casks." conflicts "--formula", "--cask" + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/extract.rb
@@ -97,7 +97,7 @@ def extract_args switch "-f", "--force", description: "Overwrite the destination formula if it already exists." - named 2 + named_args :formula, number: 2 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/formula.rb
@@ -18,7 +18,7 @@ def formula_args Display the path where <formula> is located. EOS - min_named :formula + named_args :formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/install-bundler-gems.rb
@@ -18,7 +18,7 @@ def install_bundler_gems_args Install Homebrew's Bundler gems. EOS - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/linkage.rb
@@ -28,6 +28,8 @@ def linkage_args switch "--cached", description: "Print the cached linkage values stored in `HOMEBREW_CACHE`, set by a previous "\ "`brew linkage` run." + + named_args :installed_formula end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/livecheck.rb
@@ -49,6 +49,8 @@ def livecheck_args conflicts "--debug", "--json" conflicts "--tap=", "--all", "--installed" conflicts "--cask", "--formula" + + named_args [:formula, :cask] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/man.rb
@@ -31,7 +31,7 @@ def man_args switch "--link", description: "This is now done automatically by `brew update`." - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/mirror.rb
@@ -24,7 +24,7 @@ def mirror_args switch "--no-publish", description: "Upload to Bintray, but don't publish." - min_named :formula + named_args :formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/pr-automerge.rb
@@ -34,7 +34,7 @@ def pr_automerge_args switch "--ignore-failures", description: "Include pull requests that have failing status checks." - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/pr-publish.rb
@@ -29,7 +29,7 @@ def pr_publish_args flag "--workflow=", description: "Target workflow filename (default: `publish-commit-bottles.yml`)." - min_named 1 + named_args number: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/pr-pull.rb
@@ -70,7 +70,8 @@ def pr_pull_args description: "Comma-separated list of workflows which can be ignored if they have not been run." conflicts "--clean", "--autosquash" - min_named 1 + + named_args number: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/pr-upload.rb
@@ -33,6 +33,8 @@ def pr_upload_args description: "Upload to the specified Bintray organisation (default: `homebrew`)." flag "--root-url=", description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default." + + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/prof.rb
@@ -18,6 +18,8 @@ def prof_args EOS switch "--stackprof", description: "Use `stackprof` instead of `ruby-prof` (the default)." + + named_args :command end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/release-notes.rb
@@ -25,7 +25,7 @@ def release_notes_args switch "--markdown", description: "Print as a Markdown list." - max_named 2 + named_args max: 2 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/sh.rb
@@ -27,7 +27,7 @@ def sh_args flag "-c=", "--cmd=", description: "Execute commands in a non-interactive shell." - max_named 1 + named_args max: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/sponsors.rb
@@ -17,6 +17,8 @@ def sponsors_args Print a Markdown summary of Homebrew's GitHub Sponsors, suitable for pasting into a README. EOS + + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/style.rb
@@ -42,6 +42,8 @@ def style_args conflicts "--formula", "--cask" conflicts "--only-cops", "--except-cops" + + named_args [:formula, :cask, :tap] end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/tap-new.rb
@@ -26,7 +26,8 @@ def tap_new_args description: "Initialize Git repository with the specified branch name (default: `main`)." conflicts "--no-git", "--branch" - named 1 + + named_args :tap, number: 1 end end @@ -36,8 +37,7 @@ def tap_new label = args.pull_label || "pr-pull" branch = args.branch || "main" - tap_name = args.named.first - tap = Tap.fetch(tap_name) + tap = args.named.to_taps.first raise "Invalid tap name '#{tap_name}'" unless tap.path.to_s.match?(HOMEBREW_TAP_PATH_REGEX) titleized_user = tap.user.dup
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/test.rb
@@ -30,7 +30,7 @@ def test_args switch "--retry", description: "Retry if a testing fails." - min_named :formula + named_args :installed_formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/tests.rb
@@ -34,7 +34,7 @@ def tests_args flag "--seed=", description: "Randomise tests with the specified <value> instead of a random seed." - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/typecheck.rb
@@ -37,7 +37,8 @@ def typecheck_args "in their paths (relative to the input path passed to Sorbet)." conflicts "--dir", "--file" - max_named 0 + + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/unbottled.rb
@@ -24,6 +24,8 @@ def unbottled_args switch "--total", description: "Output the number of unbottled and total formulae." conflicts "--dependents", "--total" + + named_args :formula end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/unpack.rb
@@ -30,7 +30,8 @@ def unpack_args description: "Overwrite the destination directory if it already exists." conflicts "--git", "--patch" - min_named :formula + + named_args :formula, min: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/update-license-data.rb
@@ -21,7 +21,7 @@ def update_license_data_args description: "Return a failing status code if current license data's version is the same as " \ "the upstream. This can be used to notify CI when the SPDX license data is out of date." - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/update-python-resources.rb
@@ -34,7 +34,7 @@ def update_python_resources_args comma_array "--exclude-packages=", description: "Exclude these packages when finding resources." - min_named :formula + named_args :formula, number: 1 end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/update-test.rb
@@ -26,7 +26,7 @@ def update_test_args flag "--before=", description: "Use the commit at the specified <date> as the start commit." - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/dev-cmd/vendor-gems.rb
@@ -21,7 +21,7 @@ def vendor_gems_args comma_array "--update", description: "Update all vendored Gems to the latest version." - max_named 0 + named_args :none end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/test/cask/cmd/shared_examples/requires_cask_token.rb
@@ -6,7 +6,7 @@ it "raises an exception " do expect { described_class.run - }.to raise_error(Cask::CaskUnspecifiedError, "This command requires a Cask token.") + }.to raise_error(UsageError, /this command requires a .*cask.* argument/) end end end
true
Other
Homebrew
brew
da811373d3f876da72d53c2828fd4cacefdba210.json
Add named_args DSL for commands
Library/Homebrew/test/cli/named_args_spec.rb
@@ -162,4 +162,37 @@ expect(described_class.new("foo", "baz").to_paths(only: :cask)).to eq [cask_path, Cask::CaskLoader.path("baz")] end end + + describe "#to_taps" do + it "returns taps" do + taps = described_class.new("homebrew/foo", "bar/baz") + expect(taps.to_taps.map(&:name)).to eq %w[homebrew/foo bar/baz] + end + + it "raises an error for invalid tap" do + taps = described_class.new("homebrew/foo", "barbaz") + expect { taps.to_taps }.to raise_error(RuntimeError, /Invalid tap name/) + end + end + + describe "#to_installed_taps" do + before do + (HOMEBREW_REPOSITORY/"Library/Taps/homebrew/homebrew-foo").mkpath + end + + it "returns installed taps" do + taps = described_class.new("homebrew/foo") + expect(taps.to_installed_taps.map(&:name)).to eq %w[homebrew/foo] + end + + it "raises an error for uninstalled tap" do + taps = described_class.new("homebrew/foo", "bar/baz") + expect { taps.to_installed_taps }.to raise_error(TapUnavailableError) + end + + it "raises an error for invalid tap" do + taps = described_class.new("homebrew/foo", "barbaz") + expect { taps.to_installed_taps }.to raise_error(RuntimeError, /Invalid tap name/) + end + end end
true
Other
Homebrew
brew
66f0a35587fffb32f16e51daf3091cb8781a6e10.json
keg: remove trailing whitespace.
Library/Homebrew/keg.rb
@@ -647,7 +647,7 @@ def make_relative_symlink(dst, src, **options) dst.delete if options[:overwrite] && (dst.exist? || dst.symlink?) dst.make_relative_symlink(src) rescue Errno::EEXIST => e - # Retry if we're linking a different version of the same + # Retry if we're linking a different version of the same # formula. The `AlreadyLinkedError` above won't catch # this if a formula is missing an optlink. In that case, # delete the symlink and retry.
false
Other
Homebrew
brew
2c3bc08c04e53a8bb024862c7c2b808a43b44af6.json
Update RBI files for tapioca.
Library/Homebrew/sorbet/rbi/gems/parlour@4.0.1.rbi
@@ -1,7 +0,0 @@ -# DO NOT EDIT MANUALLY -# This is an autogenerated file for types exported from the `parlour` gem. -# Please instead update this file by running `tapioca generate --exclude json`. - -# typed: true - -
true
Other
Homebrew
brew
2c3bc08c04e53a8bb024862c7c2b808a43b44af6.json
Update RBI files for tapioca.
Library/Homebrew/sorbet/rbi/gems/parlour@5.0.0.rbi
@@ -0,0 +1,1272 @@ +# DO NOT EDIT MANUALLY +# This is an autogenerated file for types exported from the `parlour` gem. +# Please instead update this file by running `tapioca sync`. + +# typed: true + +module Parlour +end + +class Parlour::ConflictResolver + sig { params(namespace: Parlour::RbiGenerator::Namespace, resolver: T.proc.params(desc: String, choices: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T.nilable(Parlour::RbiGenerator::RbiObject))).void } + def resolve_conflicts(namespace, &resolver); end + + private + + sig { params(arr: T::Array[T.untyped]).returns(T::Boolean) } + def all_eql?(arr); end + sig { params(namespace: Parlour::RbiGenerator::Namespace, name: T.nilable(String)).void } + def deduplicate_mixins_of_name(namespace, name); end + sig { params(arr: T::Array[T.untyped]).returns(T.nilable(Symbol)) } + def merge_strategy(arr); end +end + +module Parlour::Conversion +end + +class Parlour::Conversion::Converter + abstract! + + def initialize; end + + sig { params(msg: String, node: Parlour::RbiGenerator::RbiObject).void } + def add_warning(msg, node); end + sig { returns(T::Array[[String, Parlour::TypedObject]]) } + def warnings; end +end + +class Parlour::Conversion::RbiToRbs < ::Parlour::Conversion::Converter + sig { params(rbs_gen: Parlour::RbsGenerator).void } + def initialize(rbs_gen); end + + sig { params(from: Parlour::RbiGenerator::Namespace, to: Parlour::RbsGenerator::Namespace).void } + def convert_all(from, to); end + sig { params(node: Parlour::RbiGenerator::RbiObject, new_parent: Parlour::RbsGenerator::Namespace).void } + def convert_object(node, new_parent); end + sig { returns(Parlour::RbsGenerator) } + def rbs_gen; end +end + +module Parlour::Debugging + class << self + sig { params(value: T::Boolean).returns(T::Boolean) } + def debug_mode=(value); end + sig { returns(T::Boolean) } + def debug_mode?; end + sig { params(object: T.untyped, message: String).void } + def debug_puts(object, message); end + sig { params(object: T.untyped).returns(String) } + def name_for_debug_caller(object); end + end +end + +module Parlour::Debugging::Tree + class << self + sig { params(message: String).returns(String) } + def begin(message); end + sig { params(message: String).returns(String) } + def end(message); end + sig { params(message: String).returns(String) } + def here(message); end + def line_prefix; end + def text_prefix; end + end +end + +Parlour::Debugging::Tree::INDENT_SPACES = T.let(T.unsafe(nil), Integer) + +class Parlour::DetachedRbiGenerator < ::Parlour::RbiGenerator + sig { override.returns(T.nilable(Parlour::Plugin)) } + def current_plugin; end + sig { returns(T.untyped) } + def detached!; end + sig { override.returns(Parlour::Options) } + def options; end + sig { override.params(strictness: String).returns(String) } + def rbi(strictness = T.unsafe(nil)); end +end + +class Parlour::DetachedRbsGenerator < ::Parlour::RbsGenerator + sig { override.returns(T.nilable(Parlour::Plugin)) } + def current_plugin; end + sig { returns(T.untyped) } + def detached!; end + sig { override.returns(Parlour::Options) } + def options; end + sig { override.returns(String) } + def rbs; end +end + +class Parlour::Generator + sig { params(break_params: Integer, tab_size: Integer, sort_namespaces: T::Boolean).void } + def initialize(break_params: T.unsafe(nil), tab_size: T.unsafe(nil), sort_namespaces: T.unsafe(nil)); end + + sig { overridable.returns(T.nilable(Parlour::Plugin)) } + def current_plugin; end + def current_plugin=(_arg0); end + sig { overridable.returns(Parlour::Options) } + def options; end +end + +class Parlour::Options + sig { params(break_params: Integer, tab_size: Integer, sort_namespaces: T::Boolean).void } + def initialize(break_params:, tab_size:, sort_namespaces:); end + + sig { returns(Integer) } + def break_params; end + sig { params(level: Integer, str: String).returns(String) } + def indented(level, str); end + sig { returns(T::Boolean) } + def sort_namespaces; end + sig { returns(Integer) } + def tab_size; end +end + +class Parlour::ParseError < ::StandardError + def initialize(buffer, range); end + + sig { returns(Parser::Source::Buffer) } + def buffer; end + sig { returns(Parser::Source::Range) } + def range; end +end + +class Parlour::Plugin + abstract! + + sig { params(options: T::Hash[T.untyped, T.untyped]).void } + def initialize(options); end + + sig { abstract.params(root: Parlour::RbiGenerator::Namespace).void } + def generate(root); end + sig { returns(T.nilable(String)) } + def strictness; end + def strictness=(_arg0); end + + class << self + sig { params(new_plugin: T.class_of(Parlour::Plugin)).void } + def inherited(new_plugin); end + sig { returns(T::Hash[String, T.class_of(Parlour::Plugin)]) } + def registered_plugins; end + sig { params(plugins: T::Array[Parlour::Plugin], generator: Parlour::RbiGenerator, allow_failure: T::Boolean).void } + def run_plugins(plugins, generator, allow_failure: T.unsafe(nil)); end + end +end + +class Parlour::RbiGenerator < ::Parlour::Generator + def initialize(**hash); end + + sig { overridable.params(strictness: String).returns(String) } + def rbi(strictness = T.unsafe(nil)); end + sig { overridable.returns(Parlour::RbiGenerator::Namespace) } + def root; end +end + +class Parlour::RbiGenerator::Arbitrary < ::Parlour::RbiGenerator::RbiObject + sig { params(generator: Parlour::Generator, code: String, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Arbitrary).void)).void } + def initialize(generator, code: T.unsafe(nil), &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(String) } + def code; end + def code=(_arg0); end + sig { override.returns(String) } + def describe; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end +end + +class Parlour::RbiGenerator::Attribute < ::Parlour::RbiGenerator::Method + sig { params(generator: Parlour::Generator, name: String, kind: Symbol, type: T.any(Parlour::Types::Type, String), class_attribute: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Attribute).void)).void } + def initialize(generator, name, kind, type, class_attribute: T.unsafe(nil), &block); end + + sig { override.params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(T::Boolean) } + def class_attribute; end + sig { override.void } + def generalize_from_rbi!; end + sig { returns(Symbol) } + def kind; end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end + + private + + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_definition(indent_level, options); end +end + +class Parlour::RbiGenerator::ClassNamespace < ::Parlour::RbiGenerator::Namespace + sig { params(generator: Parlour::Generator, name: String, final: T::Boolean, sealed: T::Boolean, superclass: T.nilable(String), abstract: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::ClassNamespace).void)).void } + def initialize(generator, name, final, sealed, superclass, abstract, &block); end + + sig { returns(T::Boolean) } + def abstract; end + sig { override.returns(String) } + def describe; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T.nilable(String)) } + def superclass; end +end + +class Parlour::RbiGenerator::Constant < ::Parlour::RbiGenerator::RbiObject + sig { params(generator: Parlour::Generator, name: String, value: T.any(Parlour::Types::Type, String), eigen_constant: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Constant).void)).void } + def initialize(generator, name: T.unsafe(nil), value: T.unsafe(nil), eigen_constant: T.unsafe(nil), &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + def eigen_constant; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T.any(Parlour::Types::Type, String)) } + def value; end +end + +class Parlour::RbiGenerator::EnumClassNamespace < ::Parlour::RbiGenerator::ClassNamespace + sig { params(generator: Parlour::Generator, name: String, final: T::Boolean, sealed: T::Boolean, enums: T::Array[T.any(String, [String, String])], abstract: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::EnumClassNamespace).void)).void } + def initialize(generator, name, final, sealed, enums, abstract, &block); end + + sig { returns(T::Array[T.any(String, [String, String])]) } + def enums; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_body(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end +end + +class Parlour::RbiGenerator::Extend < ::Parlour::RbiGenerator::RbiObject + sig { params(generator: Parlour::Generator, name: String, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Extend).void)).void } + def initialize(generator, name: T.unsafe(nil), &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end +end + +class Parlour::RbiGenerator::Include < ::Parlour::RbiGenerator::RbiObject + sig { params(generator: Parlour::Generator, name: String, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Include).void)).void } + def initialize(generator, name: T.unsafe(nil), &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end +end + +class Parlour::RbiGenerator::Method < ::Parlour::RbiGenerator::RbiObject + sig { params(generator: Parlour::Generator, name: String, parameters: T::Array[Parlour::RbiGenerator::Parameter], return_type: T.nilable(T.any(Parlour::Types::Type, String)), abstract: T::Boolean, implementation: T::Boolean, override: T::Boolean, overridable: T::Boolean, class_method: T::Boolean, final: T::Boolean, type_parameters: T.nilable(T::Array[Symbol]), block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Method).void)).void } + def initialize(generator, name, parameters, return_type = T.unsafe(nil), abstract: T.unsafe(nil), implementation: T.unsafe(nil), override: T.unsafe(nil), overridable: T.unsafe(nil), class_method: T.unsafe(nil), final: T.unsafe(nil), type_parameters: T.unsafe(nil), &block); end + + sig { overridable.params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(T::Boolean) } + def abstract; end + sig { returns(T::Boolean) } + def class_method; end + sig { override.returns(String) } + def describe; end + sig { returns(T::Boolean) } + def final; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { returns(T::Boolean) } + def implementation; end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T::Boolean) } + def overridable; end + sig { returns(T::Boolean) } + def override; end + sig { returns(T::Array[Parlour::RbiGenerator::Parameter]) } + def parameters; end + sig { returns(T.nilable(T.any(Parlour::Types::Type, String))) } + def return_type; end + sig { returns(T::Array[Symbol]) } + def type_parameters; end + + private + + sig { overridable.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_definition(indent_level, options); end + sig { returns(String) } + def qualifiers; end +end + +class Parlour::RbiGenerator::ModuleNamespace < ::Parlour::RbiGenerator::Namespace + sig { params(generator: Parlour::Generator, name: String, final: T::Boolean, sealed: T::Boolean, interface: T::Boolean, abstract: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::ClassNamespace).void)).void } + def initialize(generator, name, final, sealed, interface, abstract, &block); end + + sig { returns(T::Boolean) } + def abstract; end + sig { override.returns(String) } + def describe; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { returns(T::Boolean) } + def interface; end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end +end + +class Parlour::RbiGenerator::Namespace < ::Parlour::RbiGenerator::RbiObject + sig { params(generator: Parlour::Generator, name: T.nilable(String), final: T::Boolean, sealed: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Namespace).void)).void } + def initialize(generator, name = T.unsafe(nil), final = T.unsafe(nil), sealed = T.unsafe(nil), &block); end + + sig { params(comment: T.any(String, T::Array[String])).void } + def add_comment_to_next_child(comment); end + sig { returns(T::Array[Parlour::RbiGenerator::TypeAlias]) } + def aliases; end + sig { returns(T::Array[Parlour::RbiGenerator::RbiObject]) } + def children; end + sig { returns(T::Array[Parlour::RbiGenerator::Constant]) } + def constants; end + def create_arbitrary(code:, &block); end + def create_attr(*args, &blk); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), class_attribute: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Attribute).void)).returns(Parlour::RbiGenerator::Attribute) } + def create_attr_accessor(name, type:, class_attribute: T.unsafe(nil), &block); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), class_attribute: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Attribute).void)).returns(Parlour::RbiGenerator::Attribute) } + def create_attr_reader(name, type:, class_attribute: T.unsafe(nil), &block); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), class_attribute: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Attribute).void)).returns(Parlour::RbiGenerator::Attribute) } + def create_attr_writer(name, type:, class_attribute: T.unsafe(nil), &block); end + sig { params(name: String, kind: Symbol, type: T.any(Parlour::Types::Type, String), class_attribute: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Attribute).void)).returns(Parlour::RbiGenerator::Attribute) } + def create_attribute(name, kind:, type:, class_attribute: T.unsafe(nil), &block); end + sig { params(name: String, final: T::Boolean, sealed: T::Boolean, superclass: T.nilable(String), abstract: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::ClassNamespace).void)).returns(Parlour::RbiGenerator::ClassNamespace) } + def create_class(name, final: T.unsafe(nil), sealed: T.unsafe(nil), superclass: T.unsafe(nil), abstract: T.unsafe(nil), &block); end + sig { params(name: String, value: String, eigen_constant: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Constant).void)).returns(Parlour::RbiGenerator::Constant) } + def create_constant(name, value:, eigen_constant: T.unsafe(nil), &block); end + sig { params(name: String, final: T::Boolean, sealed: T::Boolean, enums: T.nilable(T::Array[T.any(String, [String, String])]), abstract: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::EnumClassNamespace).void)).returns(Parlour::RbiGenerator::EnumClassNamespace) } + def create_enum_class(name, final: T.unsafe(nil), sealed: T.unsafe(nil), enums: T.unsafe(nil), abstract: T.unsafe(nil), &block); end + sig { params(name: String, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Extend).void)).returns(Parlour::RbiGenerator::Extend) } + def create_extend(name, &block); end + sig { params(extendables: T::Array[String]).returns(T::Array[Parlour::RbiGenerator::Extend]) } + def create_extends(extendables); end + sig { params(name: String, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Include).void)).returns(Parlour::RbiGenerator::Include) } + def create_include(name, &block); end + sig { params(includables: T::Array[String]).returns(T::Array[Parlour::RbiGenerator::Include]) } + def create_includes(includables); end + sig { params(name: String, parameters: T.nilable(T::Array[Parlour::RbiGenerator::Parameter]), return_type: T.nilable(T.any(Parlour::Types::Type, String)), returns: T.nilable(T.any(Parlour::Types::Type, String)), abstract: T::Boolean, implementation: T::Boolean, override: T::Boolean, overridable: T::Boolean, class_method: T::Boolean, final: T::Boolean, type_parameters: T.nilable(T::Array[Symbol]), block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::Method).void)).returns(Parlour::RbiGenerator::Method) } + def create_method(name, parameters: T.unsafe(nil), return_type: T.unsafe(nil), returns: T.unsafe(nil), abstract: T.unsafe(nil), implementation: T.unsafe(nil), override: T.unsafe(nil), overridable: T.unsafe(nil), class_method: T.unsafe(nil), final: T.unsafe(nil), type_parameters: T.unsafe(nil), &block); end + sig { params(name: String, final: T::Boolean, sealed: T::Boolean, interface: T::Boolean, abstract: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::ClassNamespace).void)).returns(Parlour::RbiGenerator::ModuleNamespace) } + def create_module(name, final: T.unsafe(nil), sealed: T.unsafe(nil), interface: T.unsafe(nil), abstract: T.unsafe(nil), &block); end + sig { params(name: String, final: T::Boolean, sealed: T::Boolean, props: T.nilable(T::Array[Parlour::RbiGenerator::StructProp]), abstract: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::StructClassNamespace).void)).returns(Parlour::RbiGenerator::StructClassNamespace) } + def create_struct_class(name, final: T.unsafe(nil), sealed: T.unsafe(nil), props: T.unsafe(nil), abstract: T.unsafe(nil), &block); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::TypeAlias).void)).returns(Parlour::RbiGenerator::TypeAlias) } + def create_type_alias(name, type:, &block); end + sig { overridable.override.returns(String) } + def describe; end + sig { returns(T::Array[Parlour::RbiGenerator::Extend]) } + def extends; end + sig { returns(T::Boolean) } + def final; end + sig { override.void } + def generalize_from_rbi!; end + sig { overridable.override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { returns(T::Array[Parlour::RbiGenerator::Include]) } + def includes; end + sig { overridable.override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { overridable.override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { params(object: T.untyped, block: T.proc.params(x: Parlour::RbiGenerator::Namespace).void).void } + def path(object, &block); end + sig { returns(T::Boolean) } + def sealed; end + def type_aliases(*args, &blk); end + + private + + sig { overridable.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_body(indent_level, options); end + sig { params(object: Parlour::RbiGenerator::RbiObject).void } + def move_next_comments(object); end +end + +Parlour::RbiGenerator::Options = Parlour::Options + +class Parlour::RbiGenerator::Parameter + sig { params(name: String, type: T.nilable(T.any(Parlour::Types::Type, String)), default: T.nilable(String)).void } + def initialize(name, type: T.unsafe(nil), default: T.unsafe(nil)); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(T.nilable(String)) } + def default; end + sig { void } + def generalize_from_rbi!; end + sig { returns(Symbol) } + def kind; end + sig { returns(String) } + def name; end + sig { returns(String) } + def name_without_kind; end + sig { returns(String) } + def to_def_param; end + sig { returns(String) } + def to_sig_param; end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +Parlour::RbiGenerator::Parameter::PREFIXES = T.let(T.unsafe(nil), Hash) + +class Parlour::RbiGenerator::RbiObject < ::Parlour::TypedObject + abstract! + + sig { params(generator: Parlour::Generator, name: String).void } + def initialize(generator, name); end + + sig { overridable.override.returns(String) } + def describe; end + sig { abstract.void } + def generalize_from_rbi!; end + sig { abstract.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { returns(Parlour::Generator) } + def generator; end + sig { abstract.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { abstract.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end +end + +class Parlour::RbiGenerator::StructClassNamespace < ::Parlour::RbiGenerator::ClassNamespace + sig { params(generator: Parlour::Generator, name: String, final: T::Boolean, sealed: T::Boolean, props: T::Array[Parlour::RbiGenerator::StructProp], abstract: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::StructClassNamespace).void)).void } + def initialize(generator, name, final, sealed, props, abstract, &block); end + + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_body(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T::Array[Parlour::RbiGenerator::StructProp]) } + def props; end +end + +class Parlour::RbiGenerator::StructProp + sig { params(name: String, type: T.any(Parlour::Types::Type, String), optional: T.nilable(T.any(Symbol, T::Boolean)), enum: T.nilable(String), dont_store: T.nilable(T::Boolean), foreign: T.nilable(String), default: T.nilable(String), factory: T.nilable(String), immutable: T.nilable(T::Boolean), array: T.nilable(String), override: T.nilable(T::Boolean), redaction: T.nilable(String)).void } + def initialize(name, type, optional: T.unsafe(nil), enum: T.unsafe(nil), dont_store: T.unsafe(nil), foreign: T.unsafe(nil), default: T.unsafe(nil), factory: T.unsafe(nil), immutable: T.unsafe(nil), array: T.unsafe(nil), override: T.unsafe(nil), redaction: T.unsafe(nil)); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(T.nilable(String)) } + def array; end + sig { returns(T.nilable(String)) } + def default; end + sig { returns(T.nilable(T::Boolean)) } + def dont_store; end + sig { returns(T.nilable(String)) } + def enum; end + sig { returns(T.nilable(String)) } + def factory; end + sig { returns(T.nilable(String)) } + def foreign; end + sig { void } + def generalize_from_rbi!; end + sig { returns(T.nilable(T::Boolean)) } + def immutable; end + sig { returns(String) } + def name; end + sig { returns(T.nilable(T.any(Symbol, T::Boolean))) } + def optional; end + sig { returns(T.nilable(T::Boolean)) } + def override; end + sig { returns(T.nilable(String)) } + def redaction; end + sig { returns(String) } + def to_prop_call; end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +Parlour::RbiGenerator::StructProp::EXTRA_PROPERTIES = T.let(T.unsafe(nil), Array) + +class Parlour::RbiGenerator::TypeAlias < ::Parlour::RbiGenerator::RbiObject + sig { params(generator: Parlour::Generator, name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbiGenerator::TypeAlias).void)).void } + def initialize(generator, name:, type:, &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.void } + def generalize_from_rbi!; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbi(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbiGenerator::RbiObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +class Parlour::RbsGenerator < ::Parlour::Generator + def initialize(**hash); end + + sig { overridable.returns(String) } + def rbs; end + sig { overridable.returns(Parlour::RbsGenerator::Namespace) } + def root; end +end + +class Parlour::RbsGenerator::Arbitrary < ::Parlour::RbsGenerator::RbsObject + sig { params(generator: Parlour::Generator, code: String, block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Arbitrary).void)).void } + def initialize(generator, code: T.unsafe(nil), &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(String) } + def code; end + def code=(_arg0); end + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end +end + +class Parlour::RbsGenerator::Attribute < ::Parlour::RbsGenerator::Method + sig { params(generator: Parlour::Generator, name: String, kind: Symbol, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Attribute).void)).void } + def initialize(generator, name, kind, type, &block); end + + sig { override.params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { returns(Symbol) } + def kind; end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +class Parlour::RbsGenerator::Block + sig { params(type: Parlour::Types::Proc, required: T::Boolean).void } + def initialize(type, required); end + + sig { overridable.params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { params(options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(options); end + sig { returns(T::Boolean) } + def required; end + sig { returns(Parlour::Types::Proc) } + def type; end +end + +class Parlour::RbsGenerator::ClassNamespace < ::Parlour::RbsGenerator::Namespace + sig { params(generator: Parlour::Generator, name: String, superclass: T.nilable(T.any(Parlour::Types::Type, String)), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::ClassNamespace).void)).void } + def initialize(generator, name, superclass, &block); end + + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T.nilable(T.any(Parlour::Types::Type, String))) } + def superclass; end +end + +class Parlour::RbsGenerator::Constant < ::Parlour::RbsGenerator::RbsObject + sig { params(generator: Parlour::Generator, name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Constant).void)).void } + def initialize(generator, name, type:, &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +class Parlour::RbsGenerator::Extend < ::Parlour::RbsGenerator::RbsObject + sig { params(generator: Parlour::Generator, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Extend).void)).void } + def initialize(generator, type:, &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +class Parlour::RbsGenerator::Include < ::Parlour::RbsGenerator::RbsObject + sig { params(generator: Parlour::Generator, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Include).void)).void } + def initialize(generator, type:, &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +class Parlour::RbsGenerator::InterfaceNamespace < ::Parlour::RbsGenerator::Namespace + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end +end + +class Parlour::RbsGenerator::Method < ::Parlour::RbsGenerator::RbsObject + sig { params(generator: Parlour::Generator, name: String, signatures: T::Array[Parlour::RbsGenerator::MethodSignature], class_method: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Method).void)).void } + def initialize(generator, name, signatures, class_method: T.unsafe(nil), &block); end + + sig { overridable.params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(T::Boolean) } + def class_method; end + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T::Array[Parlour::RbsGenerator::MethodSignature]) } + def signatures; end +end + +class Parlour::RbsGenerator::MethodSignature + sig { params(parameters: T::Array[Parlour::RbsGenerator::Parameter], return_type: T.nilable(T.any(Parlour::Types::Type, String)), block: T.nilable(Parlour::RbsGenerator::Block), type_parameters: T.nilable(T::Array[Symbol])).void } + def initialize(parameters, return_type = T.unsafe(nil), block: T.unsafe(nil), type_parameters: T.unsafe(nil)); end + + sig { overridable.params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(T.nilable(Parlour::RbsGenerator::Block)) } + def block; end + sig { params(options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(options); end + sig { returns(T::Array[Parlour::RbsGenerator::Parameter]) } + def parameters; end + sig { returns(T.nilable(T.any(Parlour::Types::Type, String))) } + def return_type; end + sig { returns(T::Array[Symbol]) } + def type_parameters; end +end + +class Parlour::RbsGenerator::ModuleNamespace < ::Parlour::RbsGenerator::Namespace + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end +end + +class Parlour::RbsGenerator::Namespace < ::Parlour::RbsGenerator::RbsObject + sig { params(generator: Parlour::Generator, name: T.nilable(String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Namespace).void)).void } + def initialize(generator, name = T.unsafe(nil), &block); end + + sig { params(comment: T.any(String, T::Array[String])).void } + def add_comment_to_next_child(comment); end + sig { returns(T::Array[Parlour::RbsGenerator::TypeAlias]) } + def aliases; end + sig { returns(T::Array[Parlour::RbsGenerator::RbsObject]) } + def children; end + sig { returns(T::Array[Parlour::RbsGenerator::Constant]) } + def constants; end + def create_arbitrary(code:, &block); end + def create_attr(*args, &blk); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Attribute).void)).returns(Parlour::RbsGenerator::Attribute) } + def create_attr_accessor(name, type:, &block); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Attribute).void)).returns(Parlour::RbsGenerator::Attribute) } + def create_attr_reader(name, type:, &block); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Attribute).void)).returns(Parlour::RbsGenerator::Attribute) } + def create_attr_writer(name, type:, &block); end + sig { params(name: String, kind: Symbol, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Attribute).void)).returns(Parlour::RbsGenerator::Attribute) } + def create_attribute(name, kind:, type:, &block); end + sig { params(name: String, superclass: T.nilable(T.any(Parlour::Types::Type, String)), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::ClassNamespace).void)).returns(Parlour::RbsGenerator::ClassNamespace) } + def create_class(name, superclass: T.unsafe(nil), &block); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Constant).void)).returns(Parlour::RbsGenerator::Constant) } + def create_constant(name, type:, &block); end + sig { params(type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Extend).void)).returns(Parlour::RbsGenerator::Extend) } + def create_extend(type, &block); end + sig { params(extendables: T::Array[T.any(Parlour::Types::Type, String)]).returns(T::Array[Parlour::RbsGenerator::Extend]) } + def create_extends(extendables); end + sig { params(type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Include).void)).returns(Parlour::RbsGenerator::Include) } + def create_include(type, &block); end + sig { params(includables: T::Array[T.any(Parlour::Types::Type, String)]).returns(T::Array[Parlour::RbsGenerator::Include]) } + def create_includes(includables); end + sig { params(name: String, block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Namespace).void)).returns(Parlour::RbsGenerator::InterfaceNamespace) } + def create_interface(name, &block); end + sig { params(name: String, signatures: T.nilable(T::Array[Parlour::RbsGenerator::MethodSignature]), class_method: T::Boolean, block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Method).void)).returns(Parlour::RbsGenerator::Method) } + def create_method(name, signatures = T.unsafe(nil), class_method: T.unsafe(nil), &block); end + sig { params(name: String, block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::Namespace).void)).returns(Parlour::RbsGenerator::ModuleNamespace) } + def create_module(name, &block); end + sig { params(name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::TypeAlias).void)).returns(Parlour::RbsGenerator::TypeAlias) } + def create_type_alias(name, type:, &block); end + sig { overridable.override.returns(String) } + def describe; end + sig { returns(T::Array[Parlour::RbsGenerator::Extend]) } + def extends; end + sig { overridable.override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { returns(T::Array[Parlour::RbsGenerator::Include]) } + def includes; end + sig { overridable.override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { overridable.override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { params(object: T.untyped, block: T.proc.params(x: Parlour::RbsGenerator::Namespace).void).void } + def path(object, &block); end + def type_aliases(*args, &blk); end + + private + + sig { overridable.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_body(indent_level, options); end + sig { params(object: Parlour::RbsGenerator::RbsObject).void } + def move_next_comments(object); end +end + +class Parlour::RbsGenerator::Parameter + sig { params(name: String, type: T.nilable(T.any(Parlour::Types::Type, String)), required: T::Boolean).void } + def initialize(name, type: T.unsafe(nil), required: T.unsafe(nil)); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(Symbol) } + def kind; end + sig { returns(String) } + def name; end + sig { returns(String) } + def name_without_kind; end + sig { returns(T::Boolean) } + def required; end + sig { returns(String) } + def to_rbs_param; end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +Parlour::RbsGenerator::Parameter::PREFIXES = T.let(T.unsafe(nil), Hash) + +Parlour::RbsGenerator::Parameter::RBS_KEYWORDS = T.let(T.unsafe(nil), Array) + +class Parlour::RbsGenerator::RbsObject < ::Parlour::TypedObject + abstract! + + sig { params(generator: Parlour::Generator, name: String).void } + def initialize(generator, name); end + + sig { overridable.override.returns(String) } + def describe; end + sig { abstract.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { returns(Parlour::Generator) } + def generator; end + sig { abstract.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { abstract.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end +end + +class Parlour::RbsGenerator::TypeAlias < ::Parlour::RbsGenerator::RbsObject + sig { params(generator: Parlour::Generator, name: String, type: T.any(Parlour::Types::Type, String), block: T.nilable(T.proc.params(x: Parlour::RbsGenerator::TypeAlias).void)).void } + def initialize(generator, name:, type:, &block); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_rbs(indent_level, options); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).void } + def merge_into_self(others); end + sig { override.params(others: T::Array[Parlour::RbsGenerator::RbsObject]).returns(T::Boolean) } + def mergeable?(others); end + sig { returns(T.any(Parlour::Types::Type, String)) } + def type; end +end + +module Parlour::TypeLoader + class << self + sig { params(filename: String, generator: T.nilable(Parlour::RbiGenerator)).returns(Parlour::RbiGenerator::Namespace) } + def load_file(filename, generator: T.unsafe(nil)); end + sig { params(root: String, inclusions: T::Array[String], exclusions: T::Array[String], generator: T.nilable(Parlour::RbiGenerator)).returns(Parlour::RbiGenerator::Namespace) } + def load_project(root, inclusions: T.unsafe(nil), exclusions: T.unsafe(nil), generator: T.unsafe(nil)); end + sig { params(source: String, filename: T.nilable(String), generator: T.nilable(Parlour::RbiGenerator)).returns(Parlour::RbiGenerator::Namespace) } + def load_source(source, filename = T.unsafe(nil), generator: T.unsafe(nil)); end + end +end + +class Parlour::TypeParser + sig { params(ast: Parser::AST::Node, unknown_node_errors: T::Boolean, generator: T.nilable(Parlour::RbiGenerator)).void } + def initialize(ast, unknown_node_errors: T.unsafe(nil), generator: T.unsafe(nil)); end + + sig { returns(Parser::AST::Node) } + def ast; end + def ast=(_arg0); end + sig { returns(Parlour::RbiGenerator) } + def generator; end + def generator=(_arg0); end + sig { returns(Parlour::RbiGenerator::Namespace) } + def parse_all; end + sig { params(path: Parlour::TypeParser::NodePath, is_within_eigenclass: T::Boolean).returns(T::Array[Parlour::RbiGenerator::Method]) } + def parse_method_into_methods(path, is_within_eigenclass: T.unsafe(nil)); end + sig { params(node: Parser::AST::Node).returns(Parlour::Types::Type) } + def parse_node_to_type(node); end + sig { params(path: Parlour::TypeParser::NodePath, is_within_eigenclass: T::Boolean).returns(T::Array[Parlour::RbiGenerator::RbiObject]) } + def parse_path_to_object(path, is_within_eigenclass: T.unsafe(nil)); end + sig { params(path: Parlour::TypeParser::NodePath, is_within_eigenclass: T::Boolean).returns(T::Array[Parlour::RbiGenerator::Method]) } + def parse_sig_into_methods(path, is_within_eigenclass: T.unsafe(nil)); end + sig { params(path: Parlour::TypeParser::NodePath).returns(Parlour::TypeParser::IntermediateSig) } + def parse_sig_into_sig(path); end + sig { returns(T::Boolean) } + def unknown_node_errors; end + + protected + + sig { params(node: T.nilable(Parser::AST::Node), modifier: Symbol).returns(T::Boolean) } + def body_has_modifier?(node, modifier); end + sig { params(node: Parser::AST::Node).returns([T::Array[String], T::Array[String]]) } + def body_includes_and_extends(node); end + sig { params(node: T.nilable(Parser::AST::Node)).returns(T::Array[Symbol]) } + def constant_names(node); end + sig { params(node: T.nilable(Parser::AST::Node)).returns(T.nilable(String)) } + def node_to_s(node); end + sig { params(desc: String, node: T.any(Parlour::TypeParser::NodePath, Parser::AST::Node)).returns(T.noreturn) } + def parse_err(desc, node); end + sig { params(path: Parlour::TypeParser::NodePath).returns(T::Boolean) } + def previous_sibling_sig_node?(path); end + sig { params(node: Parser::AST::Node).returns(T::Boolean) } + def sig_node?(node); end + sig { params(msg: String, node: Parser::AST::Node).void } + def warning(msg, node); end + sig { type_parameters(:A, :B).params(a: T::Array[T.type_parameter(:A)], fa: T.proc.params(item: T.type_parameter(:A)).returns(T.untyped), b: T::Array[T.type_parameter(:B)], fb: T.proc.params(item: T.type_parameter(:B)).returns(T.untyped)).returns(T::Array[[T.type_parameter(:A), T.type_parameter(:B)]]) } + def zip_by(a, fa, b, fb); end + + class << self + sig { params(filename: String, source: String, generator: T.nilable(Parlour::RbiGenerator)).returns(Parlour::TypeParser) } + def from_source(filename, source, generator: T.unsafe(nil)); end + sig { params(str: String).returns(Parlour::Types::Type) } + def parse_single_type(str); end + end +end + +class Parlour::TypeParser::IntermediateSig < ::T::Struct + prop :type_parameters, T.nilable(T::Array[Symbol]) + prop :overridable, T::Boolean + prop :override, T::Boolean + prop :abstract, T::Boolean + prop :final, T::Boolean + prop :return_type, T.nilable(String) + prop :params, T.nilable(T::Array[Parser::AST::Node]) + + class << self + def inherited(s); end + end +end + +class Parlour::TypeParser::NodePath + sig { params(indices: T::Array[Integer]).void } + def initialize(indices); end + + sig { params(index: Integer).returns(Parlour::TypeParser::NodePath) } + def child(index); end + sig { returns(T::Array[Integer]) } + def indices; end + sig { returns(Parlour::TypeParser::NodePath) } + def parent; end + sig { params(offset: Integer).returns(Parlour::TypeParser::NodePath) } + def sibling(offset); end + sig { params(start: Parser::AST::Node).returns(Parser::AST::Node) } + def traverse(start); end +end + +class Parlour::TypedObject + abstract! + + sig { params(name: String).void } + def initialize(name); end + + sig { params(comment: T.any(String, T::Array[String])).void } + def add_comment(comment); end + def add_comments(*args, &blk); end + sig { returns(T::Array[String]) } + def comments; end + sig { abstract.returns(String) } + def describe; end + sig { returns(T.nilable(Parlour::Plugin)) } + def generated_by; end + sig { returns(String) } + def name; end + + protected + + sig { params(indent_level: Integer, options: Parlour::Options).returns(T::Array[String]) } + def generate_comments(indent_level, options); end +end + +module Parlour::Types +end + +class Parlour::Types::Array < ::Parlour::Types::SingleElementCollection + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def collection_name; end +end + +class Parlour::Types::Boolean < ::Parlour::Types::Type + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end +end + +class Parlour::Types::Class < ::Parlour::Types::Type + sig { params(type: T.any(Parlour::Types::Type, String)).void } + def initialize(type); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(Parlour::Types::Type) } + def type; end +end + +class Parlour::Types::Enumerable < ::Parlour::Types::SingleElementCollection + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def collection_name; end +end + +class Parlour::Types::Enumerator < ::Parlour::Types::SingleElementCollection + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def collection_name; end +end + +class Parlour::Types::Generic < ::Parlour::Types::Type + sig { params(type: T.any(Parlour::Types::Type, String), type_params: T::Array[T.any(Parlour::Types::Type, String)]).void } + def initialize(type, type_params); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(Parlour::Types::Type) } + def type; end + sig { returns(T::Array[Parlour::Types::Type]) } + def type_params; end +end + +class Parlour::Types::Hash < ::Parlour::Types::Type + sig { params(key: T.any(Parlour::Types::Type, String), value: T.any(Parlour::Types::Type, String)).void } + def initialize(key, value); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(Parlour::Types::Type) } + def key; end + sig { returns(Parlour::Types::Type) } + def value; end +end + +class Parlour::Types::Intersection < ::Parlour::Types::Type + sig { params(types: T::Array[T.any(Parlour::Types::Type, String)]).void } + def initialize(types); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(T::Array[Parlour::Types::Type]) } + def types; end +end + +class Parlour::Types::Nilable < ::Parlour::Types::Type + sig { params(type: T.any(Parlour::Types::Type, String)).void } + def initialize(type); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(Parlour::Types::Type) } + def type; end +end + +class Parlour::Types::Proc < ::Parlour::Types::Type + sig { params(parameters: T::Array[Parlour::Types::Proc::Parameter], return_type: T.nilable(T.any(Parlour::Types::Type, String))).void } + def initialize(parameters, return_type); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(T::Array[Parlour::Types::Proc::Parameter]) } + def parameters; end + sig { returns(T.nilable(Parlour::Types::Type)) } + def return_type; end +end + +class Parlour::Types::Proc::Parameter + sig { params(name: String, type: T.any(Parlour::Types::Type, String), default: T.nilable(String)).void } + def initialize(name, type, default = T.unsafe(nil)); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { returns(T.nilable(String)) } + def default; end + sig { returns(String) } + def name; end + sig { returns(Parlour::Types::Type) } + def type; end +end + +class Parlour::Types::Range < ::Parlour::Types::SingleElementCollection + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def collection_name; end +end + +class Parlour::Types::Raw < ::Parlour::Types::Type + sig { params(str: String).void } + def initialize(str); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(String) } + def str; end +end + +class Parlour::Types::Record < ::Parlour::Types::Type + sig { params(keys_to_types: T::Hash[Symbol, T.any(Parlour::Types::Type, String)]).void } + def initialize(keys_to_types); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(T::Hash[Symbol, Parlour::Types::Type]) } + def keys_to_types; end +end + +class Parlour::Types::Self < ::Parlour::Types::Type + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end +end + +class Parlour::Types::Set < ::Parlour::Types::SingleElementCollection + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def collection_name; end +end + +class Parlour::Types::SingleElementCollection < ::Parlour::Types::Type + abstract! + + sig { params(element: T.any(Parlour::Types::Type, String)).void } + def initialize(element); end + + sig { abstract.returns(String) } + def collection_name; end + sig { override.returns(String) } + def describe; end + sig { returns(Parlour::Types::Type) } + def element; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end +end + +class Parlour::Types::Tuple < ::Parlour::Types::Type + sig { params(types: T::Array[T.any(Parlour::Types::Type, String)]).void } + def initialize(types); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(T::Array[Parlour::Types::Type]) } + def types; end +end + +class Parlour::Types::Type + abstract! + + def initialize(*args, &blk); end + + sig { abstract.returns(String) } + def describe; end + sig { abstract.returns(String) } + def generate_rbi; end + sig { abstract.returns(String) } + def generate_rbs; end + def hash; end + sig { params(type_like: T.any(Parlour::Types::Type, String)).returns(Parlour::Types::Type) } + def to_type(type_like); end + + class << self + sig { params(type_like: T.any(Parlour::Types::Type, String)).returns(Parlour::Types::Type) } + def to_type(type_like); end + end +end + +class Parlour::Types::Union < ::Parlour::Types::Type + sig { params(types: T::Array[T.any(Parlour::Types::Type, String)]).void } + def initialize(types); end + + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end + sig { returns(T::Array[Parlour::Types::Type]) } + def types; end +end + +class Parlour::Types::Untyped < ::Parlour::Types::Type + sig { params(other: Object).returns(T::Boolean) } + def ==(other); end + sig { override.returns(String) } + def describe; end + sig { override.returns(String) } + def generate_rbi; end + sig { override.returns(String) } + def generate_rbs; end +end + +Parlour::VERSION = T.let(T.unsafe(nil), String)
true
Other
Homebrew
brew
2c3bc08c04e53a8bb024862c7c2b808a43b44af6.json
Update RBI files for tapioca.
Library/Homebrew/sorbet/rbi/gems/tapioca@0.4.11.rbi
@@ -146,6 +146,8 @@ class Tapioca::Compilers::SymbolTable::SymbolGenerator def add_to_alias_namespace(name); end sig { params(name: String).returns(T::Boolean) } def alias_namespaced?(name); end + sig { params(constant: Module).returns(T::Array[Module]) } + def ancestors_of(constant); end sig { params(constant: Module, other: BasicObject).returns(T::Boolean) } def are_equal?(constant, other); end sig { params(constant: BasicObject).returns(Class) } @@ -194,7 +196,11 @@ class Tapioca::Compilers::SymbolTable::SymbolGenerator def get_file_candidates(constant); end sig { params(str: String).returns(String) } def indented(str); end + sig { params(constant: Module).returns(T::Array[Module]) } + def inherited_ancestors_of(constant); end def initialize_method_for(constant); end + sig { params(constant: Module).returns(T::Array[Module]) } + def interesting_ancestors_of(constant); end sig { params(name: String).void } def mark_seen(name); end sig { params(method: UnboundMethod).returns(T::Boolean) } @@ -205,20 +211,22 @@ class Tapioca::Compilers::SymbolTable::SymbolGenerator def name_of(constant); end sig { params(constant: Module).returns(T.nilable(String)) } def name_of_proxy_target(constant); end + sig { params(object: Object).returns(T::Boolean) } + def object_id_of(object); end def parent_declares_constant?(name); end sig { params(constant: Module).returns(T::Boolean) } def public_module?(constant); end sig { params(constant: Module).returns(T.nilable(String)) } def qualified_name_of(constant); end sig { params(constant: Module).returns(T.nilable(String)) } def raw_name_of(constant); end - sig { params(symbol: String).returns(BasicObject) } - def resolve_constant(symbol); end + sig { params(symbol: String, inherit: T::Boolean).returns(BasicObject) } + def resolve_constant(symbol, inherit: T.unsafe(nil)); end sig { params(name: String).returns(T::Boolean) } def seen?(name); end sig { params(method: T.any(Method, UnboundMethod)).returns(T.untyped) } def signature_of(method); end - sig { params(constant: BasicObject).returns(Class) } + sig { params(constant: Module).returns(Class) } def singleton_class_of(constant); end sig { params(constant: Module, method_name: String).returns(T::Boolean) } def struct_method?(constant, method_name); end
true
Other
Homebrew
brew
2c3bc08c04e53a8bb024862c7c2b808a43b44af6.json
Update RBI files for tapioca.
Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
@@ -12631,68 +12631,43 @@ module ParallelTests def self.with_ruby_binary(command); end end -module Parlour - VERSION = ::T.let(nil, ::T.untyped) -end - -class Parlour::ConflictResolver - def resolve_conflicts(*args, &blk); end -end - class Parlour::ConflictResolver extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks end -module Parlour::Debugging -end - -module Parlour::Debugging::Tree - INDENT_SPACES = ::T.let(nil, ::T.untyped) +class Parlour::Conversion::Converter + extend ::T::Sig + extend ::T::Helpers + extend ::T::Private::Abstract::Hooks + extend ::T::InterfaceWrapper::Helpers + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks end module Parlour::Debugging::Tree extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks - def self.begin(*args, &blk); end - - def self.end(*args, &blk); end - - def self.here(*args, &blk); end - - def self.line_prefix(); end - - def self.text_prefix(); end end module Parlour::Debugging extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks - def self.debug_mode=(*args, &blk); end - - def self.debug_mode?(*args, &blk); end - - def self.debug_puts(*args, &blk); end - - def self.name_for_debug_caller(*args, &blk); end -end - -class Parlour::DetachedRbiGenerator - def detached!(*args, &blk); end end -class Parlour::DetachedRbiGenerator +class Parlour::Generator + extend ::T::Sig + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::ParseError - def buffer(*args, &blk); end - - def initialize(buffer, range); end - - def range(*args, &blk); end +class Parlour::Options + extend ::T::Sig + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks end class Parlour::ParseError @@ -12701,438 +12676,89 @@ class Parlour::ParseError extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::Plugin - def generate(*args, &blk); end - - def initialize(*args, &blk); end - - def strictness(*args, &blk); end - - def strictness=(strictness); end -end - class Parlour::Plugin extend ::T::Sig extend ::T::Helpers extend ::T::Private::Abstract::Hooks extend ::T::InterfaceWrapper::Helpers extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks - def self.inherited(*args, &blk); end - - def self.registered_plugins(*args, &blk); end - - def self.run_plugins(*args, &blk); end -end - -class Parlour::RbiGenerator - def current_plugin(*args, &blk); end - - def current_plugin=(current_plugin); end - - def initialize(*args, &blk); end - - def options(*args, &blk); end - - def rbi(*args, &blk); end - - def root(*args, &blk); end -end - -class Parlour::RbiGenerator::Arbitrary - def ==(*args, &blk); end - - def code(*args, &blk); end - - def code=(code); end -end - -class Parlour::RbiGenerator::Arbitrary -end - -class Parlour::RbiGenerator::Attribute - def class_attribute(*args, &blk); end - - def kind(*args, &blk); end -end - -class Parlour::RbiGenerator::Attribute -end - -class Parlour::RbiGenerator::ClassNamespace - def abstract(*args, &blk); end - - def superclass(*args, &blk); end -end - -class Parlour::RbiGenerator::ClassNamespace -end - -class Parlour::RbiGenerator::Constant - def ==(*args, &blk); end - - def eigen_constant(); end - - def value(*args, &blk); end -end - -class Parlour::RbiGenerator::Constant -end - -class Parlour::RbiGenerator::EnumClassNamespace - def enums(*args, &blk); end -end - -class Parlour::RbiGenerator::EnumClassNamespace -end - -class Parlour::RbiGenerator::Extend - def ==(*args, &blk); end -end - -class Parlour::RbiGenerator::Extend -end - -class Parlour::RbiGenerator::Include - def ==(*args, &blk); end -end - -class Parlour::RbiGenerator::Include -end - -class Parlour::RbiGenerator::Method - def ==(*args, &blk); end - - def abstract(*args, &blk); end - - def class_method(*args, &blk); end - - def final(*args, &blk); end - - def implementation(*args, &blk); end - - def overridable(*args, &blk); end - - def override(*args, &blk); end - - def parameters(*args, &blk); end - - def return_type(*args, &blk); end - - def type_parameters(*args, &blk); end -end - -class Parlour::RbiGenerator::Method -end - -class Parlour::RbiGenerator::ModuleNamespace - def interface(*args, &blk); end -end - -class Parlour::RbiGenerator::ModuleNamespace -end - -class Parlour::RbiGenerator::Namespace - def add_comment_to_next_child(*args, &blk); end - - def children(*args, &blk); end - - def constants(*args, &blk); end - - def create_arbitrary(code:, &block); end - - def create_attr(*args, &blk); end - - def create_attr_accessor(*args, &blk); end - - def create_attr_reader(*args, &blk); end - - def create_attr_writer(*args, &blk); end - - def create_attribute(*args, &blk); end - - def create_class(*args, &blk); end - - def create_constant(*args, &blk); end - - def create_enum_class(*args, &blk); end - - def create_extend(*args, &blk); end - - def create_extends(*args, &blk); end - - def create_include(*args, &blk); end - - def create_includes(*args, &blk); end - - def create_method(*args, &blk); end - - def create_module(*args, &blk); end - - def create_struct_class(*args, &blk); end - - def create_type_alias(*args, &blk); end - - def extends(*args, &blk); end - - def final(*args, &blk); end - - def includes(*args, &blk); end - - def path(*args, &blk); end -end - -class Parlour::RbiGenerator::Namespace -end - -class Parlour::RbiGenerator::Options - def break_params(*args, &blk); end - - def indented(*args, &blk); end - - def initialize(*args, &blk); end - - def sort_namespaces(*args, &blk); end - - def tab_size(*args, &blk); end end -class Parlour::RbiGenerator::Options +class Parlour::RbiGenerator::Parameter extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::RbiGenerator::Parameter - def ==(*args, &blk); end - - def default(*args, &blk); end - - def initialize(*args, &blk); end - - def kind(*args, &blk); end - - def name(*args, &blk); end - - def name_without_kind(*args, &blk); end - - def to_def_param(*args, &blk); end - - def to_sig_param(*args, &blk); end - - def type(*args, &blk); end - PREFIXES = ::T.let(nil, ::T.untyped) -end - -class Parlour::RbiGenerator::Parameter +class Parlour::RbiGenerator::StructProp extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::RbiGenerator::RbiObject - def add_comment(*args, &blk); end - - def add_comments(*args, &blk); end - - def comments(*args, &blk); end - - def describe(*args, &blk); end - - def generate_rbi(*args, &blk); end - - def generated_by(*args, &blk); end - - def generator(*args, &blk); end - - def initialize(*args, &blk); end - - def merge_into_self(*args, &blk); end - - def mergeable?(*args, &blk); end - - def name(*args, &blk); end -end - -class Parlour::RbiGenerator::RbiObject - extend ::T::Helpers +class Parlour::RbsGenerator::Block extend ::T::Sig - extend ::T::Private::Abstract::Hooks - extend ::T::InterfaceWrapper::Helpers extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::RbiGenerator::StructClassNamespace - def props(*args, &blk); end -end - -class Parlour::RbiGenerator::StructClassNamespace -end - -class Parlour::RbiGenerator::StructProp - def ==(*args, &blk); end - - def array(*args, &blk); end - - def default(*args, &blk); end - - def dont_store(*args, &blk); end - - def enum(*args, &blk); end - - def factory(*args, &blk); end - - def foreign(*args, &blk); end - - def immutable(*args, &blk); end - - def initialize(*args, &blk); end - - def name(*args, &blk); end - - def optional(*args, &blk); end - - def override(*args, &blk); end - - def redaction(*args, &blk); end - - def to_prop_call(*args, &blk); end - - def type(*args, &blk); end - EXTRA_PROPERTIES = ::T.let(nil, ::T.untyped) -end - -class Parlour::RbiGenerator::StructProp +class Parlour::RbsGenerator::MethodSignature extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::RbiGenerator +class Parlour::RbsGenerator::Parameter extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks end module Parlour::TypeLoader + extend ::T::Sig + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks end -module Parlour::TypeLoader +class Parlour::TypeParser::NodePath extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks - def self.load_file(*args, &blk); end - - def self.load_project(*args, &blk); end - - def self.load_source(*args, &blk); end end class Parlour::TypeParser - def ast(*args, &blk); end - - def ast=(ast); end - - def body_has_modifier?(*args, &blk); end - - def body_includes_and_extends(*args, &blk); end - - def constant_names(*args, &blk); end - - def generator(*args, &blk); end - - def generator=(generator); end - - def initialize(*args, &blk); end - - def node_to_s(*args, &blk); end - - def parse_all(*args, &blk); end - - def parse_err(*args, &blk); end - - def parse_method_into_methods(*args, &blk); end - - def parse_path_to_object(*args, &blk); end - - def parse_sig_into_methods(*args, &blk); end - - def parse_sig_into_sig(*args, &blk); end - - def previous_sibling_sig_node?(*args, &blk); end - - def sig_node?(*args, &blk); end - - def unknown_node_errors(*args, &blk); end - - def zip_by(*args, &blk); end -end - -class Parlour::TypeParser::IntermediateSig - def abstract(); end - - def abstract=(val); end - - def final(); end - - def final=(val); end - - def initialize(*args, &blk); end - - def overridable(); end - - def overridable=(val); end - - def override(); end - - def override=(val); end - - def params(); end - - def params=(val); end - - def return_type(); end - - def return_type=(val); end - - def type_parameters(); end - - def type_parameters=(val); end + extend ::T::Sig + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::TypeParser::IntermediateSig - def self.inherited(s); end +class Parlour::TypedObject + extend ::T::Sig + extend ::T::Helpers + extend ::T::Private::Abstract::Hooks + extend ::T::InterfaceWrapper::Helpers + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::TypeParser::NodePath - def child(*args, &blk); end - - def indices(*args, &blk); end - - def initialize(*args, &blk); end - - def parent(*args, &blk); end - - def sibling(*args, &blk); end - - def traverse(*args, &blk); end +module Parlour::Types + TypeLike = ::T.let(nil, ::T.untyped) end -class Parlour::TypeParser::NodePath +class Parlour::Types::Proc::Parameter extend ::T::Sig extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks end -class Parlour::TypeParser +class Parlour::Types::Type extend ::T::Sig + extend ::T::Helpers + extend ::T::Private::Abstract::Hooks + extend ::T::InterfaceWrapper::Helpers extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks - def self.from_source(*args, &blk); end -end - -module Parlour end class Parser::Ruby24 @@ -30043,6 +29669,11 @@ class Utils::AST::FormulaAST extend ::T::Private::Methods::SingletonMethodHooks end +module Utils::AST + extend ::T::Private::Methods::MethodHooks + extend ::T::Private::Methods::SingletonMethodHooks +end + module Utils::Analytics extend ::T::Private::Methods::SingletonMethodHooks end
true
Other
Homebrew
brew
92b58666efaa469628fe72b4dbe5a8d741b74e51.json
Improve audit for `livecheck` in casks.
Library/Homebrew/cask/audit.rb
@@ -67,6 +67,7 @@ def run! check_single_uninstall_zap check_untrusted_pkg check_hosting_with_appcast + check_appcast_and_livecheck check_latest_with_appcast_or_livecheck check_latest_with_auto_updates check_stanza_requires_uninstall @@ -283,18 +284,24 @@ def check_sha256_invalid add_error "cannot use the sha256 for an empty string: #{empty_sha256}" end + def check_appcast_and_livecheck + return unless cask.appcast + + add_error "Cask has a `livecheck`, the `appcast` should be removed." if cask.livecheckable? + end + def check_latest_with_appcast_or_livecheck return unless cask.version.latest? - add_error "Casks with an appcast should not use version :latest" if cask.appcast - add_error "Casks with a livecheck should not use version :latest" if cask.livecheckable? + add_error "Casks with an `appcast` should not use `version :latest`." if cask.appcast + add_error "Casks with a `livecheck` should not use `version :latest`." if cask.livecheckable? end def check_latest_with_auto_updates return unless cask.version.latest? return unless cask.auto_updates - add_error "Casks with `version :latest` should not use `auto_updates`" + add_error "Casks with `version :latest` should not use `auto_updates`." end def check_hosting_with_appcast
true
Other
Homebrew
brew
92b58666efaa469628fe72b4dbe5a8d741b74e51.json
Improve audit for `livecheck` in casks.
Library/Homebrew/test/cask/audit_spec.rb
@@ -647,7 +647,7 @@ def tmp_cask(name, text) end describe "latest with appcast checks" do - let(:message) { "Casks with an appcast should not use version :latest" } + let(:message) { "Casks with an `appcast` should not use `version :latest`." } context "when the Cask is :latest and does not have an appcast" do let(:cask_token) { "version-latest" } @@ -691,7 +691,7 @@ def tmp_cask(name, text) end describe "latest with auto_updates checks" do - let(:message) { "Casks with `version :latest` should not use `auto_updates`" } + let(:message) { "Casks with `version :latest` should not use `auto_updates`." } context "when the Cask is :latest and does not have auto_updates" do let(:cask_token) { "version-latest" }
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/brew.rb
@@ -85,16 +85,14 @@ class MissingEnvironmentVariables < RuntimeError; end ENV["PATH"] = path require "commands" + require "settings" if cmd internal_cmd = Commands.valid_internal_cmd?(cmd) internal_cmd ||= begin internal_dev_cmd = Commands.valid_internal_dev_cmd?(cmd) if internal_dev_cmd && !Homebrew::EnvConfig.developer? - if (HOMEBREW_REPOSITORY/".git/config").exist? - system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config", - "--replace-all", "homebrew.devcmdrun", "true" - end + Settings.write "devcmdrun", true ENV["HOMEBREW_DEV_CMD_RUN"] = "1" end internal_dev_cmd
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/cmd/update-report.rb
@@ -8,6 +8,7 @@ require "cleanup" require "description_cache_store" require "cli/parser" +require "settings" module Homebrew extend T::Sig @@ -63,16 +64,12 @@ def update_report Utils::Analytics.messages_displayed! if $stdout.tty? end - HOMEBREW_REPOSITORY.cd do - donation_message_displayed = - Utils.popen_read("git", "config", "--get", "homebrew.donationmessage").chomp == "true" - if !donation_message_displayed && !args.quiet? - ohai "Homebrew is run entirely by unpaid volunteers. Please consider donating:" - puts " #{Formatter.url("https://github.com/Homebrew/brew#donations")}\n" + if Settings.read("donationmessage") != "true" && !args.quiet? + ohai "Homebrew is run entirely by unpaid volunteers. Please consider donating:" + puts " #{Formatter.url("https://github.com/Homebrew/brew#donations")}\n" - # Consider the message possibly missed if not a TTY. - safe_system "git", "config", "--replace-all", "homebrew.donationmessage", "true" if $stdout.tty? - end + # Consider the message possibly missed if not a TTY. + Settings.write "donationmessage", true if $stdout.tty? end install_core_tap_if_necessary @@ -89,19 +86,14 @@ def update_report puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}." updated = true - old_tag = if (HOMEBREW_REPOSITORY/".git/config").exist? - Utils.popen_read( - "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config", "--get", "homebrew.latesttag" - ).chomp.presence - end + old_tag = Settings.read "latesttag" new_tag = Utils.popen_read( "git", "-C", HOMEBREW_REPOSITORY, "tag", "--list", "--sort=-version:refname", "*.*" ).lines.first.chomp if new_tag != old_tag - system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config", - "--replace-all", "homebrew.latesttag", new_tag + Settings.write "latesttag", new_tag new_repository_version = new_tag end end
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/completions.rb
@@ -2,6 +2,7 @@ # frozen_string_literal: true require "utils/link" +require "settings" # Helper functions for generating shell completions. # @@ -13,15 +14,15 @@ module Completions sig { void } def link! - write_completions_option "yes" + Settings.write :linkcompletions, true Tap.each do |tap| Utils::Link.link_completions tap.path, "brew completions link" end end sig { void } def unlink! - write_completions_option "no" + Settings.write :linkcompletions, false Tap.each do |tap| next if tap.official? @@ -31,7 +32,7 @@ def unlink! sig { returns(T::Boolean) } def link_completions? - read_completions_option == "yes" + Settings.read(:linkcompletions) == "true" end sig { returns(T::Boolean) } @@ -48,23 +49,9 @@ def completions_to_link? false end - sig { params(option: String).returns(String) } - def read_completions_option(option: "linkcompletions") - HOMEBREW_REPOSITORY.cd do - Utils.popen_read("git", "config", "--get", "homebrew.#{option}").chomp - end - end - - sig { params(state: String, option: String).void } - def write_completions_option(state, option: "linkcompletions") - HOMEBREW_REPOSITORY.cd do - T.unsafe(self).safe_system "git", "config", "--replace-all", "homebrew.#{option}", state.to_s - end - end - sig { void } def show_completions_message_if_needed - return if read_completions_option(option: "completionsmessageshown") == "yes" + return if Settings.read(:completionsmessageshown) == "true" return unless completions_to_link? T.unsafe(self).ohai "Homebrew completions for external commands are unlinked by default!" @@ -74,6 +61,6 @@ def show_completions_message_if_needed Then, follow the directions at #{Formatter.url("https://docs.brew.sh/Shell-Completion")} EOS - write_completions_option("yes", option: "completionsmessageshown") + Settings.write :completionsmessageshown, true end end
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/settings.rb
@@ -0,0 +1,39 @@ +# typed: true +# frozen_string_literal: true + +# Helper functions for reading and writing settings. +# +# @api private +module Settings + extend T::Sig + + module_function + + sig { params(setting: T.any(String, Symbol), repo: Pathname).returns(T.nilable(String)) } + def read(setting, repo: HOMEBREW_REPOSITORY) + return unless (repo/".git/config").exist? + + repo.cd do + Utils.popen_read("git", "config", "--get", "homebrew.#{setting}").chomp.presence + end + end + + sig { params(setting: T.any(String, Symbol), value: T.any(String, T::Boolean), repo: Pathname).void } + def write(setting, value, repo: HOMEBREW_REPOSITORY) + return unless (repo/".git/config").exist? + + repo.cd do + T.unsafe(self).safe_system "git", "config", "--replace-all", "homebrew.#{setting}", value.to_s + end + end + + sig { params(setting: T.any(String, Symbol), repo: Pathname).void } + def delete(setting, repo: HOMEBREW_REPOSITORY) + return unless (repo/".git/config").exist? + return if read(setting, repo: repo).blank? + + repo.cd do + T.unsafe(self).safe_system "git", "config", "--unset-all", "homebrew.#{setting}" + end + end +end
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/tap.rb
@@ -5,6 +5,7 @@ require "completions" require "extend/cachable" require "description_cache_store" +require "settings" # A {Tap} is used to extend the formulae provided by Homebrew core. # Usually, it's synced with a remote Git repository. And it's likely @@ -821,18 +822,14 @@ def [](key) return unless tap.git? return unless Utils::Git.available? - tap.path.cd do - Utils.popen_read("git", "config", "--get", "homebrew.#{key}").chomp.presence - end + Settings.read key, repo: tap.path end def []=(key, value) return unless tap.git? return unless Utils::Git.available? - tap.path.cd do - safe_system "git", "config", "--replace-all", "homebrew.#{key}", value.to_s - end + Settings.write key, value.to_s, repo: tap.path end end
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/test/completions_spec.rb
@@ -0,0 +1,143 @@ +# typed: false +# frozen_string_literal: true + +require "completions" + +describe Completions do + let(:internal_path) { HOMEBREW_REPOSITORY/"Library/Taps/homebrew/homebrew-bar" } + let(:external_path) { HOMEBREW_REPOSITORY/"Library/Taps/foo/homebrew-bar" } + + before do + HOMEBREW_REPOSITORY.cd do + system "git", "init" + end + internal_path.mkpath + external_path.mkpath + end + + def setup_completions(external:) + (internal_path/"completions/bash/foo_internal").write "#foo completions" + if external + (external_path/"completions/bash/foo_external").write "#foo completions" + elsif (external_path/"completions/bash/foo_external").exist? + (external_path/"completions/bash/foo_external").delete + end + end + + def setup_completions_setting(state, setting: "linkcompletions") + HOMEBREW_REPOSITORY.cd do + system "git", "config", "--replace-all", "homebrew.#{setting}", state.to_s + end + end + + def read_completions_setting(setting: "linkcompletions") + HOMEBREW_REPOSITORY.cd do + Utils.popen_read("git", "config", "--get", "homebrew.#{setting}").chomp.presence + end + end + + def delete_completions_setting(setting: "linkcompletions") + HOMEBREW_REPOSITORY.cd do + system "git", "config", "--unset-all", "homebrew.#{setting}" + end + end + + after do + FileUtils.rm_rf internal_path + FileUtils.rm_rf external_path.dirname + end + + describe ".link!" do + it "sets homebrew.linkcompletions to true" do + setup_completions_setting false + expect { described_class.link! }.not_to raise_error + expect(read_completions_setting).to eq "true" + end + + it "sets homebrew.linkcompletions to true if unset" do + delete_completions_setting + expect { described_class.link! }.not_to raise_error + expect(read_completions_setting).to eq "true" + end + + it "keeps homebrew.linkcompletions set to true" do + setup_completions_setting true + expect { described_class.link! }.not_to raise_error + expect(read_completions_setting).to eq "true" + end + end + + describe ".unlink!" do + it "sets homebrew.linkcompletions to false" do + setup_completions_setting true + expect { described_class.unlink! }.not_to raise_error + expect(read_completions_setting).to eq "false" + end + + it "sets homebrew.linkcompletions to false if unset" do + delete_completions_setting + expect { described_class.unlink! }.not_to raise_error + expect(read_completions_setting).to eq "false" + end + + it "keeps homebrew.linkcompletions set to false" do + setup_completions_setting false + expect { described_class.unlink! }.not_to raise_error + expect(read_completions_setting).to eq "false" + end + end + + describe ".link_completions?" do + it "returns true if homebrew.linkcompletions is true" do + setup_completions_setting true + expect(described_class.link_completions?).to be true + end + + it "returns false if homebrew.linkcompletions is false" do + setup_completions_setting false + expect(described_class.link_completions?).to be false + end + + it "returns false if homebrew.linkcompletions is not set" do + expect(described_class.link_completions?).to be false + end + end + + describe ".completions_to_link?" do + it "returns false if only internal taps have completions" do + setup_completions external: false + expect(described_class.completions_to_link?).to be false + end + + it "returns true if external taps have completions" do + setup_completions external: true + expect(described_class.completions_to_link?).to be true + end + end + + describe ".show_completions_message_if_needed" do + it "doesn't show the message if there are no completions to link" do + setup_completions external: false + delete_completions_setting setting: :completionsmessageshown + expect { described_class.show_completions_message_if_needed }.not_to output.to_stdout + end + + it "doesn't show the message if there are completions to link but the message has already been shown" do + setup_completions external: true + setup_completions_setting true, setting: :completionsmessageshown + expect { described_class.show_completions_message_if_needed }.not_to output.to_stdout + end + + it "shows the message if there are completions to link and the message hasn't already been shown" do + setup_completions external: true + delete_completions_setting setting: :completionsmessageshown + + # This will fail because the method calls `puts`. + # If we output the `ohai` andcatch the error, we can be usre that the message is showing. + error_message = "private method `puts' called for Completions:Module" + expect { described_class.show_completions_message_if_needed } + .to output.to_stdout + .and raise_error(NoMethodError, error_message) + end + end +end
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/test/settings_spec.rb
@@ -0,0 +1,74 @@ +# typed: false +# frozen_string_literal: true + +require "settings" + +describe Settings do + before do + HOMEBREW_REPOSITORY.cd do + system "git", "init" + end + end + + def setup_setting + HOMEBREW_REPOSITORY.cd do + system "git", "config", "--replace-all", "homebrew.foo", "true" + end + end + + describe ".read" do + it "returns the correct value for a setting" do + setup_setting + expect(described_class.read("foo")).to eq "true" + end + + it "returns the correct value for a setting as a symbol" do + setup_setting + expect(described_class.read(:foo)).to eq "true" + end + + it "returns nil when setting is not set" do + setup_setting + expect(described_class.read("bar")).to be_nil + end + + it "runs on a repo without a configuration file" do + expect { described_class.read("foo", repo: HOMEBREW_REPOSITORY/"bar") }.not_to raise_error + end + end + + describe ".write" do + it "writes over an existing value" do + setup_setting + described_class.write :foo, false + expect(described_class.read("foo")).to eq "false" + end + + it "writes a new value" do + setup_setting + described_class.write :bar, "abcde" + expect(described_class.read("bar")).to eq "abcde" + end + + it "returns if the repo doesn't have a configuration file" do + expect { described_class.write("foo", repo: HOMEBREW_REPOSITORY/"bar") }.not_to raise_error + end + end + + describe ".delete" do + it "deletes an existing setting" do + setup_setting + described_class.delete(:foo) + expect(described_class.read("foo")).to be_nil + end + + it "deletes a non-existing setting" do + setup_setting + expect { described_class.delete(:bar) }.not_to raise_error + end + + it "returns if the repo doesn't have a configuration file" do + expect { described_class.delete("foo", repo: HOMEBREW_REPOSITORY/"bar") }.not_to raise_error + end + end +end
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/test/tap_spec.rb
@@ -87,8 +87,8 @@ def setup_git_repo def setup_completion(link:) HOMEBREW_REPOSITORY.cd do system "git", "init" - system "git", "config", "--replace-all", "homebrew.linkcompletions", link - system "git", "config", "--replace-all", "homebrew.completionsmessageshown", "yes" + system "git", "config", "--replace-all", "homebrew.linkcompletions", link.to_s + system "git", "config", "--replace-all", "homebrew.completionsmessageshown", "true" end end @@ -293,7 +293,7 @@ def setup_completion(link:) specify "#install and #uninstall" do setup_tap_files setup_git_repo - setup_completion link: "yes" + setup_completion link: true tap = described_class.new("Homebrew", "bar") @@ -320,7 +320,7 @@ def setup_completion(link:) specify "#link_completions_and_manpages when completions are enabled for non-official tap" do setup_tap_files setup_git_repo - setup_completion link: "yes" + setup_completion link: true tap = described_class.new("NotHomebrew", "baz") tap.install clone_target: subject.path/".git" (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete @@ -341,7 +341,7 @@ def setup_completion(link:) specify "#link_completions_and_manpages when completions are disabled for non-official tap" do setup_tap_files setup_git_repo - setup_completion link: "no" + setup_completion link: false tap = described_class.new("NotHomebrew", "baz") tap.install clone_target: subject.path/".git" (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete @@ -359,7 +359,7 @@ def setup_completion(link:) specify "#link_completions_and_manpages when completions are enabled for official tap" do setup_tap_files setup_git_repo - setup_completion link: "no" + setup_completion link: false tap = described_class.new("Homebrew", "baz") tap.install clone_target: subject.path/".git" (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
true
Other
Homebrew
brew
f1f3fdc315238e6f86892f6228f7da5c5eb462a3.json
settings: add module for managing git config settings
Library/Homebrew/utils/analytics.rb
@@ -3,6 +3,7 @@ require "context" require "erb" +require "settings" module Utils # Helper module for fetching and reporting analytics data. @@ -102,27 +103,27 @@ def no_message_output? end def uuid - config_get(:analyticsuuid) + Settings.read :analyticsuuid end def messages_displayed! - config_set(:analyticsmessage, true) - config_set(:caskanalyticsmessage, true) + Settings.write :analyticsmessage, true + Settings.write :caskanalyticsmessage, true end def enable! - config_set(:analyticsdisabled, false) + Settings.write :analyticsdisabled, false messages_displayed! end def disable! - config_set(:analyticsdisabled, true) + Settings.write :analyticsdisabled, true regenerate_uuid! end def regenerate_uuid! # it will be regenerated in next run unless disabled. - config_delete(:analyticsuuid) + Settings.delete :analyticsuuid end def output(args:, filter: nil) @@ -313,25 +314,7 @@ def table_output(category, days, results, os_version: false, cask_install: false end def config_true?(key) - config_get(key) == "true" - end - - def config_get(key) - HOMEBREW_REPOSITORY.cd do - Utils.popen_read("git", "config", "--get", "homebrew.#{key}").chomp - end - end - - def config_set(key, value) - HOMEBREW_REPOSITORY.cd do - safe_system "git", "config", "--replace-all", "homebrew.#{key}", value.to_s - end - end - - def config_delete(key) - HOMEBREW_REPOSITORY.cd do - system "git", "config", "--unset-all", "homebrew.#{key}" - end + Settings.read(key) == "true" end def formulae_brew_sh_json(endpoint)
true
Other
Homebrew
brew
eefe5bb2959c77aa93a6b4a1884644fedbd8b730.json
git_repository: add `safe` argument to `git_head`/`git_short_head`
Library/Homebrew/extend/git_repository.rb
@@ -32,20 +32,21 @@ def git_origin=(origin) end # Gets the full commit hash of the HEAD commit. - sig { returns(T.nilable(String)) } - def git_head + sig { params(safe: T::Boolean).returns(T.nilable(String)) } + def git_head(safe: false) return if !git? || !Utils::Git.available? - Utils.popen_read(Utils::Git.git, "rev-parse", "--verify", "-q", "HEAD", chdir: self).chomp.presence + Utils.popen_read(Utils::Git.git, "rev-parse", "--verify", "-q", "HEAD", safe: safe, chdir: self).chomp.presence end # Gets a short commit hash of the HEAD commit. - sig { params(length: T.nilable(Integer)).returns(T.nilable(String)) } - def git_short_head(length: nil) + sig { params(length: T.nilable(Integer), safe: T::Boolean).returns(T.nilable(String)) } + def git_short_head(length: nil, safe: false) return if !git? || !Utils::Git.available? + git = Utils::Git.git short_arg = length&.to_s&.prepend("=") - Utils.popen_read(Utils::Git.git, "rev-parse", "--short#{short_arg}", "--verify", "-q", "HEAD", chdir: self) + Utils.popen_read(git, "rev-parse", "--short#{short_arg}", "--verify", "-q", "HEAD", safe: safe, chdir: self) .chomp.presence end
true
Other
Homebrew
brew
eefe5bb2959c77aa93a6b4a1884644fedbd8b730.json
git_repository: add `safe` argument to `git_head`/`git_short_head`
Library/Homebrew/utils/git_repository.rb
@@ -4,17 +4,21 @@ module Utils extend T::Sig - sig { params(repo: T.any(String, Pathname), length: T.nilable(Integer)).returns(T.nilable(String)) } - def self.git_head(repo, length: nil) + sig do + params(repo: T.any(String, Pathname), length: T.nilable(Integer), safe: T::Boolean).returns(T.nilable(String)) + end + def self.git_head(repo, length: nil, safe: true) return git_short_head(repo, length: length) if length.present? repo = Pathname(repo).extend(GitRepositoryExtension) - repo.git_head + repo.git_head(safe: safe) end - sig { params(repo: T.any(String, Pathname), length: T.nilable(Integer)).returns(T.nilable(String)) } - def self.git_short_head(repo, length: nil) + sig do + params(repo: T.any(String, Pathname), length: T.nilable(Integer), safe: T::Boolean).returns(T.nilable(String)) + end + def self.git_short_head(repo, length: nil, safe: true) repo = Pathname(repo).extend(GitRepositoryExtension) - repo.git_short_head(length: length) + repo.git_short_head(length: length, safe: safe) end end
true
Other
Homebrew
brew
f81e89193e51459f7ec0ff02ddf3b8529f2411f8.json
rubocops: update helpers for rubocop v1 API
Library/Homebrew/rubocops/checksum.rb
@@ -28,7 +28,6 @@ def audit_sha256(checksum) return if checksum.nil? if regex_match_group(checksum, /^$/) - @offense_source_range = @offensive_node.source_range problem "sha256 is empty" return end
true
Other
Homebrew
brew
f81e89193e51459f7ec0ff02ddf3b8529f2411f8.json
rubocops: update helpers for rubocop v1 API
Library/Homebrew/rubocops/components_order.rb
@@ -27,7 +27,6 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) if on_macos_blocks.length > 1 @offensive_node = on_macos_blocks.second - @offense_source_range = on_macos_blocks.second.source_range problem "there can only be one `on_macos` block in a formula." end @@ -37,7 +36,6 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) if on_linux_blocks.length > 1 @offensive_node = on_linux_blocks.second - @offense_source_range = on_linux_blocks.second.source_range problem "there can only be one `on_linux` block in a formula." end @@ -58,7 +56,6 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) end @offensive_node = resource_block - @offense_source_range = resource_block.source_range next if on_macos_blocks.length.zero? && on_linux_blocks.length.zero? @@ -122,7 +119,6 @@ def check_on_os_block_content(component_precedence_list, on_os_block) valid_node ||= on_os_allowed_methods.include? child.method_name.to_s @offensive_node = child - @offense_source_range = child.source_range next if valid_node problem "`#{on_os_block.method_name}` cannot include `#{child.method_name}`. " \
true
Other
Homebrew
brew
f81e89193e51459f7ec0ff02ddf3b8529f2411f8.json
rubocops: update helpers for rubocop v1 API
Library/Homebrew/rubocops/extend/formula.rb
@@ -18,7 +18,7 @@ module Cop # Superclass for all formula cops. # # @api private - class FormulaCop < Cop + class FormulaCop < Base include RangeHelp include HelperFunctions @@ -71,19 +71,16 @@ def find_node_method_by_name(node, method_name) next unless method_node.method_name == method_name @offensive_node = method_node - @offense_source_range = method_node.source_range return method_node end # If not found then, parent node becomes the offensive node @offensive_node = node.parent - @offense_source_range = node.parent.source_range nil end # Sets the given node as the offending node when required in custom cops. def offending_node(node) @offensive_node = node - @offense_source_range = node.source_range end # Returns an array of method call nodes matching method_name inside node with depth first order (child nodes). @@ -142,7 +139,6 @@ def find_instance_method_call(node, instance, method_name) next if method.receiver.const_name != instance && !(method.receiver.send_type? && method.receiver.method_name == instance) - @offense_source_range = method.source_range @offensive_node = method return true unless block_given? @@ -160,7 +156,6 @@ def find_instance_call(node, name) next if method_node.receiver.const_name != name && !(method_node.receiver.send_type? && method_node.receiver.method_name == name) - @offense_source_range = method_node.receiver.source_range @offensive_node = method_node.receiver return true unless block_given? @@ -179,7 +174,6 @@ def depends_on?(dependency_name, *types) end return if idx.nil? - @offense_source_range = dependency_nodes[idx].source_range @offensive_node = dependency_nodes[idx] end @@ -207,10 +201,7 @@ def depends_on_name_type?(node, name = nil, type = :required) type_match = false end - if type_match || name_match - @offensive_node = node - @offense_source_range = node.source_range - end + @offensive_node = node if type_match || name_match type_match && name_match end @@ -223,7 +214,6 @@ def find_const(node, const_name) next unless const_node.const_name == const_name @offensive_node = const_node - @offense_source_range = const_node.source_range yield const_node if block_given? return true end @@ -259,12 +249,10 @@ def find_block(node, block_name) next if block_node.method_name != block_name @offensive_node = block_node - @offense_source_range = block_node.source_range return block_node end # If not found then, parent node becomes the offensive node @offensive_node = node.parent - @offense_source_range = node.parent.source_range nil end @@ -299,14 +287,12 @@ def find_method_def(node, method_name = nil) next if method_name != def_method_name && method_name.present? @offensive_node = def_node - @offense_source_range = def_node.source_range return def_node end return if node.parent.nil? # If not found then, parent node becomes the offensive node @offensive_node = node.parent - @offense_source_range = node.parent.source_range nil end @@ -317,7 +303,6 @@ def method_called_in_block?(node, method_name) next unless call_node.method_name == method_name @offensive_node = call_node - @offense_source_range = call_node.source_range return true end false @@ -345,7 +330,6 @@ def method_called_ever?(node, method_name) next unless call_node.method_name == method_name @offensive_node = call_node - @offense_source_range = call_node.source_range return true end false @@ -365,7 +349,6 @@ def check_precedence(first_nodes, next_nodes) def component_precedes?(first_node, next_node) return false if line_number(first_node) < line_number(next_node) - @offense_source_range = first_node.source_range @offensive_node = first_node true end @@ -394,7 +377,6 @@ def parameters(method_node) def parameters_passed?(method_node, *params) method_params = parameters(method_node) @offensive_node = method_node - @offense_source_range = method_node.source_range params.all? do |given_param| method_params.any? do |method_param| if given_param.instance_of?(Regexp) @@ -420,9 +402,8 @@ def get_checksum_node(call) # Yields to a block with comment text as parameter. def audit_comments - @processed_source.comments.each do |comment_node| + processed_source.comments.each do |comment_node| @offensive_node = comment_node - @offense_source_range = :expression yield comment_node.text end end @@ -435,7 +416,6 @@ def end_column(node) # Returns the class node's name, or nil if not a class node. def class_name(node) @offensive_node = node - @offense_source_range = node.source_range node.const_name end
true
Other
Homebrew
brew
f81e89193e51459f7ec0ff02ddf3b8529f2411f8.json
rubocops: update helpers for rubocop v1 API
Library/Homebrew/rubocops/lines.rb
@@ -534,7 +534,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) "Pass explicit paths to prevent Homebrew from removing empty folders." end - if find_method_def(@processed_source.ast) + if find_method_def(processed_source.ast) problem "Define method #{method_name(@offensive_node)} in the class body, not at the top-level" end
true
Other
Homebrew
brew
f81e89193e51459f7ec0ff02ddf3b8529f2411f8.json
rubocops: update helpers for rubocop v1 API
Library/Homebrew/rubocops/shared/desc_helper.rb
@@ -27,7 +27,6 @@ def audit_desc(type, name, desc_call) end @offensive_node = desc_call - @offense_source_range = desc_call.source_range desc = desc_call.first_argument
true
Other
Homebrew
brew
f81e89193e51459f7ec0ff02ddf3b8529f2411f8.json
rubocops: update helpers for rubocop v1 API
Library/Homebrew/rubocops/shared/helper_functions.rb
@@ -28,7 +28,6 @@ def regex_match_group(node, pattern) @length = match_object.to_s.length @line_no = line_number(node) @source_buf = source_buffer(node) - @offense_source_range = source_range(@source_buf, @line_no, @column, @length) @offensive_node = node match_object end @@ -77,8 +76,8 @@ def string_content(node) end end - def problem(msg) - add_offense(@offensive_node, location: @offense_source_range, message: msg) + def problem(msg, &block) + add_offense(@offensive_node, message: msg, &block) end end end
true
Other
Homebrew
brew
14b4916ddabe5b3349643f847fc140a00b2f8179.json
utils/ast: move helper functions from `FormulaAST` to `AST`
Library/Homebrew/dev-cmd/bottle.rb
@@ -574,7 +574,7 @@ def old_checksums(formula, formula_ast, bottle_hash, args:) end return [] unless args.keep_old? - old_keys = Utils::AST::FormulaAST.body_children(bottle_node.body).map(&:method_name) + old_keys = Utils::AST.body_children(bottle_node.body).map(&:method_name) old_bottle_spec = formula.bottle_specification mismatches, checksums = merge_bottle_spec(old_keys, old_bottle_spec, bottle_hash["bottle"]) if mismatches.present?
true
Other
Homebrew
brew
14b4916ddabe5b3349643f847fc140a00b2f8179.json
utils/ast: move helper functions from `FormulaAST` to `AST`
Library/Homebrew/test/utils/ast/ast_spec.rb
@@ -0,0 +1,50 @@ +# typed: false +# frozen_string_literal: true + +require "utils/ast" + +describe Utils::AST do + describe ".stanza_text" do + let(:compound_license) do + <<~RUBY.chomp + license all_of: [ + :public_domain, + "MIT", + "GPL-3.0-or-later" => { with: "Autoconf-exception-3.0" }, + ] + RUBY + end + + it "accepts existing stanza text" do + expect(described_class.stanza_text(:revision, "revision 1")).to eq("revision 1") + expect(described_class.stanza_text(:license, "license :public_domain")).to eq("license :public_domain") + expect(described_class.stanza_text(:license, 'license "MIT"')).to eq('license "MIT"') + expect(described_class.stanza_text(:license, compound_license)).to eq(compound_license) + end + + it "accepts a number as the stanza value" do + expect(described_class.stanza_text(:revision, 1)).to eq("revision 1") + end + + it "accepts a symbol as the stanza value" do + expect(described_class.stanza_text(:license, :public_domain)).to eq("license :public_domain") + end + + it "accepts a string as the stanza value" do + expect(described_class.stanza_text(:license, "MIT")).to eq('license "MIT"') + end + + it "adds indent to stanza text if specified" do + expect(described_class.stanza_text(:revision, "revision 1", indent: 2)).to eq(" revision 1") + expect(described_class.stanza_text(:license, 'license "MIT"', indent: 2)).to eq(' license "MIT"') + expect(described_class.stanza_text(:license, compound_license, indent: 2)).to eq(compound_license.indent(2)) + end + + it "does not add indent if already indented" do + expect(described_class.stanza_text(:revision, " revision 1", indent: 2)).to eq(" revision 1") + expect( + described_class.stanza_text(:license, compound_license.indent(2), indent: 2), + ).to eq(compound_license.indent(2)) + end + end +end
true
Other
Homebrew
brew
14b4916ddabe5b3349643f847fc140a00b2f8179.json
utils/ast: move helper functions from `FormulaAST` to `AST`
Library/Homebrew/test/utils/ast/formula_ast_spec.rb
@@ -46,50 +46,6 @@ class Foo < Formula end end - describe ".stanza_text" do - let(:compound_license) do - <<~RUBY.chomp - license all_of: [ - :public_domain, - "MIT", - "GPL-3.0-or-later" => { with: "Autoconf-exception-3.0" }, - ] - RUBY - end - - it "accepts existing stanza text" do - expect(described_class.stanza_text(:revision, "revision 1")).to eq("revision 1") - expect(described_class.stanza_text(:license, "license :public_domain")).to eq("license :public_domain") - expect(described_class.stanza_text(:license, 'license "MIT"')).to eq('license "MIT"') - expect(described_class.stanza_text(:license, compound_license)).to eq(compound_license) - end - - it "accepts a number as the stanza value" do - expect(described_class.stanza_text(:revision, 1)).to eq("revision 1") - end - - it "accepts a symbol as the stanza value" do - expect(described_class.stanza_text(:license, :public_domain)).to eq("license :public_domain") - end - - it "accepts a string as the stanza value" do - expect(described_class.stanza_text(:license, "MIT")).to eq('license "MIT"') - end - - it "adds indent to stanza text if specified" do - expect(described_class.stanza_text(:revision, "revision 1", indent: 2)).to eq(" revision 1") - expect(described_class.stanza_text(:license, 'license "MIT"', indent: 2)).to eq(' license "MIT"') - expect(described_class.stanza_text(:license, compound_license, indent: 2)).to eq(compound_license.indent(2)) - end - - it "does not add indent if already indented" do - expect(described_class.stanza_text(:revision, " revision 1", indent: 2)).to eq(" revision 1") - expect( - described_class.stanza_text(:license, compound_license.indent(2), indent: 2), - ).to eq(compound_license.indent(2)) - end - end - describe "#add_bottle_block" do let(:bottle_output) do <<~RUBY.chomp.indent(2)
true
Other
Homebrew
brew
14b4916ddabe5b3349643f847fc140a00b2f8179.json
utils/ast: move helper functions from `FormulaAST` to `AST`
Library/Homebrew/utils/ast.rb
@@ -9,18 +9,79 @@ module Utils # # @api private module AST + extend T::Sig + Node = RuboCop::AST::Node SendNode = RuboCop::AST::SendNode BlockNode = RuboCop::AST::BlockNode ProcessedSource = RuboCop::AST::ProcessedSource TreeRewriter = Parser::Source::TreeRewriter + module_function + + sig { params(body_node: Node).returns(T::Array[Node]) } + def body_children(body_node) + if body_node.blank? + [] + elsif body_node.begin_type? + body_node.children.compact + else + [body_node] + end + end + + sig { params(name: Symbol, value: T.any(Numeric, String, Symbol), indent: T.nilable(Integer)).returns(String) } + def stanza_text(name, value, indent: nil) + text = if value.is_a?(String) + _, node = process_source(value) + value if (node.is_a?(SendNode) || node.is_a?(BlockNode)) && node.method_name == name + end + text ||= "#{name} #{value.inspect}" + text = text.indent(indent) if indent && !text.match?(/\A\n* +/) + text + end + + sig { params(source: String).returns([ProcessedSource, Node]) } + def process_source(source) + ruby_version = Version.new(HOMEBREW_REQUIRED_RUBY_VERSION).major_minor.to_f + processed_source = ProcessedSource.new(source, ruby_version) + root_node = processed_source.ast + [processed_source, root_node] + end + + sig do + params( + component_name: Symbol, + component_type: Symbol, + target_name: Symbol, + target_type: T.nilable(Symbol), + ).returns(T::Boolean) + end + def component_match?(component_name:, component_type:, target_name:, target_type: nil) + component_name == target_name && (target_type.nil? || component_type == target_type) + end + + sig { params(node: Node, name: Symbol, type: T.nilable(Symbol)).returns(T::Boolean) } + def call_node_match?(node, name:, type: nil) + node_type = case node + when SendNode then :method_call + when BlockNode then :block_call + else return false + end + + component_match?(component_name: node.method_name, + component_type: node_type, + target_name: name, + target_type: type) + end + # Helper class for editing formulae. # # @api private class FormulaAST extend T::Sig extend Forwardable + include AST delegate process: :tree_rewriter @@ -33,17 +94,6 @@ def initialize(formula_contents) @tree_rewriter = T.let(TreeRewriter.new(processed_source.buffer), TreeRewriter) end - sig { params(body_node: Node).returns(T::Array[Node]) } - def self.body_children(body_node) - if body_node.nil? - [] - elsif body_node.begin_type? - body_node.children.compact - else - [body_node] - end - end - sig { returns(T.nilable(Node)) } def bottle_block stanza(:bottle, type: :block_call) @@ -66,10 +116,10 @@ def add_bottle_block(bottle_output) sig { params(name: Symbol, replacement: T.any(Numeric, String, Symbol), type: T.nilable(Symbol)).void } def replace_stanza(name, replacement, type: nil) - stanza_node = children.find { |child| call_node_match?(child, name: name, type: type) } - raise "Could not find #{name} stanza!" if stanza_node.nil? + stanza_node = stanza(name, type: type) + raise "Could not find `#{name}` stanza!" if stanza_node.blank? - tree_rewriter.replace(stanza_node.source_range, self.class.stanza_text(name, replacement, indent: 2).lstrip) + tree_rewriter.replace(stanza_node.source_range, stanza_text(name, replacement, indent: 2).lstrip) end sig { params(name: Symbol, value: T.any(Numeric, String, Symbol), type: T.nilable(Symbol)).void } @@ -104,26 +154,7 @@ def add_stanza(name, value, type: nil) end end - tree_rewriter.insert_after(preceding_expr, "\n#{self.class.stanza_text(name, value, indent: 2)}") - end - - sig { params(name: Symbol, value: T.any(Numeric, String, Symbol), indent: T.nilable(Integer)).returns(String) } - def self.stanza_text(name, value, indent: nil) - text = if value.is_a?(String) - _, node = process_source(value) - value if (node.is_a?(SendNode) || node.is_a?(BlockNode)) && node.method_name == name - end - text ||= "#{name} #{value.inspect}" - text = text.indent(indent) if indent && !text.match?(/\A\n* +/) - text - end - - sig { params(source: String).returns([ProcessedSource, Node]) } - def self.process_source(source) - ruby_version = Version.new(HOMEBREW_REQUIRED_RUBY_VERSION).major_minor.to_f - processed_source = ProcessedSource.new(source, ruby_version) - root_node = processed_source.ast - [processed_source, root_node] + tree_rewriter.insert_after(preceding_expr, "\n#{stanza_text(name, value, indent: 2)}") end private @@ -142,7 +173,7 @@ def self.process_source(source) sig { returns([ProcessedSource, T::Array[Node]]) } def process_formula - processed_source, root_node = self.class.process_source(formula_contents) + processed_source, root_node = process_source(formula_contents) class_node = root_node if root_node.class_type? if root_node.begin_type? @@ -156,7 +187,7 @@ def process_formula raise "Could not find formula class!" if class_node.nil? - children = self.class.body_children(class_node.body) + children = body_children(class_node.body) raise "Formula class is empty!" if children.empty? [processed_source, children] @@ -178,32 +209,6 @@ def formula_component_before_target?(node, target_name:, target_type: nil) false end - - sig do - params( - component_name: Symbol, - component_type: Symbol, - target_name: Symbol, - target_type: T.nilable(Symbol), - ).returns(T::Boolean) - end - def component_match?(component_name:, component_type:, target_name:, target_type: nil) - component_name == target_name && (target_type.nil? || component_type == target_type) - end - - sig { params(node: Node, name: Symbol, type: T.nilable(Symbol)).returns(T::Boolean) } - def call_node_match?(node, name:, type: nil) - node_type = case node - when SendNode then :method_call - when BlockNode then :block_call - else return false - end - - component_match?(component_name: node.method_name, - component_type: node_type, - target_name: name, - target_type: type) - end end end end
true
Other
Homebrew
brew
8c6f41d2648beec4fa6548a8de90d1a6bf2453d9.json
sorbet: Update RBI files. Autogenerated by the [sorbet](https://github.com/Homebrew/brew/blob/master/.github/workflows/sorbet.yml) workflow.
Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
@@ -30038,7 +30038,8 @@ class User extend ::T::Private::Methods::SingletonMethodHooks end -module Utils::AST +class Utils::AST::FormulaAST + extend ::T::Private::Methods::MethodHooks extend ::T::Private::Methods::SingletonMethodHooks end
false
Other
Homebrew
brew
308390ba5b7fe03e5ed899c70e49faa47044ace8.json
Address feedback and expand documentation Co-authored-by: Mike McQuaid <mike@mikemcquaid.com> Co-authored-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
Library/Homebrew/livecheck.rb
@@ -6,7 +6,8 @@ # also return the related instance variable when no argument is provided. # # This information is used by the `brew livecheck` command to control its -# behavior. +# behavior. Example `livecheck` blocks can be found in the +# [`brew livecheck` documentation](https://docs.brew.sh/Brew-Livecheck). class Livecheck extend Forwardable
true
Other
Homebrew
brew
308390ba5b7fe03e5ed899c70e49faa47044ace8.json
Address feedback and expand documentation Co-authored-by: Mike McQuaid <mike@mikemcquaid.com> Co-authored-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
Library/Homebrew/livecheck/strategy/sourceforge.rb
@@ -21,7 +21,7 @@ module Strategy # pushed out of the feed (especially if it hasn't been updated recently). # # Usually we address this situation by adding a `livecheck` block to - # the formula that checks the page for the relevant directory in the + # the formula/cask that checks the page for the relevant directory in the # project instead. In this situation, it's necessary to use # `strategy :page_match` to prevent the {Sourceforge} stratgy from # being used.
true
Other
Homebrew
brew
308390ba5b7fe03e5ed899c70e49faa47044ace8.json
Address feedback and expand documentation Co-authored-by: Mike McQuaid <mike@mikemcquaid.com> Co-authored-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
docs/Brew-Livecheck.md
@@ -1,115 +1,137 @@ -# Brew Livecheck +# `brew livecheck` -**NOTE: This document is a work in progress and will be revised and expanded as time permits.** +The `brew livecheck` command finds the newest version of a formula or cask's software by checking upstream. Livecheck has [strategies](https://rubydoc.brew.sh/Homebrew/Livecheck/Strategy.html) to identify versions from various sources, such as Git repositories, websites, etc. -**NOTE: `livecheck` blocks are currently found in separate files in the [Homebrew/homebrew-livecheck](https://github.com/Homebrew/homebrew-livecheck) repository's `Livecheckables` folder. These will be migrated to their respective formulae in Homebrew/homebrew-core in the near future and this document is written as if this migration has already happened.** +## Behavior -The general purpose of the `brew livecheck` command is to find the newest version of a formula's software by checking an upstream source. Livecheck has [built-in strategies](#built-in-strategies) that can identify versions from some popular sources, such as Git repositories, certain websites, etc. +When livecheck isn't given instructions for how to check for upstream versions, it does the following by default: -## Default behavior +1. For formulae: Collect the `head`, `stable`, and `homepage` URLs, in that order. For casks: Collect the `url` and `homepage` URLs, in that order. +1. Determine if any strategies apply to the first URL. If not, try the next URL. +1. If a strategy can be applied, use it to check for new versions. +1. Return the newest version (or an error if versions could not be found at any available URLs). -When livecheck isn't given instructions for how to check for upstream versions of a formula's software, it does the following by default: +It's sometimes necessary to override this default behavior to create a working check for a formula/cask. If a source doesn't provide the newest version, we need to check a different one. If livecheck doesn't correctly match version text, we need to provide an appropriate regex. -1. Collect the `head`, `stable`, and `homepage` URLs from the formula, in that order. -2. Determine if any of the available strategies can be applied to the first URL. Move on to the next URL if no strategies apply. -3. If a strategy can be applied, use it to check for new versions. -4. Return the newest version (or an error if versions could not be found at any available URLs). +This can be accomplished by adding a `livecheck` block to the formula/cask. For more information on the available methods, please refer to the [`Livecheck` class documentation](https://rubydoc.brew.sh/Livecheck.html). -This approach works fine for a number of formulae without requiring any manual intervention. However, it's sometimes necessary to change livecheck's default behavior to create a working check for a formula. +## Creating a check -It may be that the source livecheck is using doesn't provide the newest version and we need to check a different one instead. In another case, livecheck may be matching a version it shouldn't and we need to provide a regex to only match what's appropriate. +1. **Use the debug output to understand the situation**. `brew livecheck --debug <formula>|<cask>` provides information about which URLs livecheck tries, any strategies that apply, matched versions, etc. -## The `livecheck` block +1. **Research available sources to select a URL**. Try removing the file name from `stable`/`url`, to see if this is a directory listing page. If that doesn't work, try to find a page that links to the file (e.g. a download page). If it's not possible to find the newest version on the website, try checking other sources from the formula/cask. When necessary, search for other sources outside of the formula/cask. -We can control livecheck's behavior by providing a `livecheck` block in the formula. Here is a simple example to check a "downloads" page for links containing a filename like `example-1.2.tar.gz`: +1. **Create a regex, if necessary**. If the check works without a regex and wouldn't benefit from having one, it's usually fine to omit it. More information on creating regexes can be found in the [regex guidelines](#regex-guidelines) section. -```ruby -livecheck do - url "https://www.example.com/downloads/" - regex(/href=.*?example[._-]v?(\d+(?:\.\d+)+)\.t/i) -end -``` +### General guidelines -At the moment, it's only necessary to create a `livecheck` block in a formula when the default check doesn't work properly. +* **Only use `strategy` when it's necessary**. For example, if livecheck is already using `Git` for a URL, it's not necessary to use `strategy :git`. However, if `Git` applies to a URL but we need to use `PageMatch`, it's necessary to use `strategy :page_match`. -## Creating a check +* **Only use the `GithubLatest` strategy when it's necessary and correct**. Github.com rate limits requests and we try to minimize our use of this strategy to avoid hitting the rate limit on CI or when using `brew livecheck --tap` on large taps (e.g. homebrew/core). The `Git` strategy is often sufficient and we only need to use `GithubLatest` when the "latest" release is different than the newest version from the tags. -1. **Use the debug output to understand the current situation**. Running `brew livecheck --debug <formula>` (where `<formula>` is the formula name) will provide more information about which URL livecheck is using and any strategy that applies. +### URL guidelines -2. **Research available sources**. It's generally preferable to check for a new version at the same source as the `stable` URL, when possible. With this in mind, it may be a good idea to start by removing the file name from the `stable` URL, to see if this is a directory listing page. If that doesn't work, the website may have a downloads page we can check for versions. If it's not possible to find the newest version at this source through any means, try checking other sources from the formula (e.g. an upstream Git repository or the homepage). It's also sometimes necessary to search for other sources outside of the formula. +* **A `url` is required in a `livecheck` block**. This can be a URL string (e.g. `"https://www.example.com/downloads/"`) or a formula/cask URL symbol (i.e. `:stable`, `:url`, `:head`, `:homepage`). The exception to this rule is a `livecheck` block that only uses `skip`. -3. **Compare available versions between sources**. If the latest version is available from the `stable` source, it's best to use that. Otherwise, check the other sources to identify where the latest version is available. +* **Check for versions in the same location as the stable archive, whenever possible**. -4. **Select a source**. After researching and comparing sources, decide which one is the best available option and use it as the `url` in the `livecheck` block. +* **Avoid checking paginated release pages, when possible**. For example, we generally avoid checking the `release` page for a GitHub project because the latest stable version can be pushed off the first page by pre-release versions. In this scenario, it's more reliable to use the `Git` strategy, which fetches all the tags in the repository. -5. **Create a regex, if necessary or beneficial**. If the check works fine without a regex and wouldn't benefit from having one, it's fine to omit it. However, when a default check isn't working properly and we need to create a `livecheck` block, a regex is almost always necessary as well. More information on creating regexes can be found in the [regex guidelines](#regex-guidelines) section. +### Regex guidelines -6. **Verify the check is working as intended**. Run `brew livecheck --debug <formula>` again to ensure livecheck is identifying all the versions it should and properly returning the newest version at the end. +The `livecheck` block regex restricts matches to a subset of the fetched content and uses a capture group around the version text. -### URL guidelines +* **Regexes should be made case insensitive, whenever possible**, by adding `i` at the end (e.g. `/.../i` or `%r{...}i`). This improves reliability, as the regex will handle changes in letter case without needing modifications. -* **A `url` is a required part of a `livecheck` block** and can either be a string containing a URL (e.g. `"https://www.example.com/downloads/"`) or a symbol referencing one of the supported formula URLs (i.e. `:stable`, `:homepage`, or `:head`). +* **Regexes should only use a capturing group around the version text**. For example, in `/href=.*?example-v?(\d+(?:\.\d+)+)(?:-src)?\.t/i`, we're only using a capturing group around the version test (matching a version like `1.2`, `1.2.3`, etc.) and we're using non-capturing groups elsewhere (e.g. `(?:-src)?`). -* **Use a symbol for a formula URL (i.e. `:homepage`, `:stable`, and `:head`) when appropriate**, to avoid duplicating formula URLs in the livecheckable. +* **Anchor the start/end of the regex, to restrict the scope**. For example, on HTML pages we often match file names or version directories in `href` attribute URLs (e.g. `/href=.*?example[._-]v?(\d+(?:\.\d+)+)\.zip/i`). The general idea is that limiting scope will help exclude unwanted matches. -* **It's generally preferable to check for versions in the same location as the stable archive, when possible**. This preference is stronger for first-party sources (websites, repositories, etc.) and becomes weaker for third-party sources (e.g. mirrors, another software package manager, etc.). +* **Avoid generic catch-alls like `.*` or `.+`** in favor of something non-greedy and/or contextually appropriate. For example, to match characters within the bounds of an HTML attribute, use `[^"' >]+?`. -### Regex guidelines +* **Use `[._-]` in place of a period/underscore/hyphen between the software name and version in a file name**. For a file named `example-1.2.3.tar.gz`, `example[._-]v?(\d+(?:\.\d+)+)\.t` will continue matching if the upstream file name format changes to `example_1.2.3.tar.gz` or `example.1.2.3.tar.gz`. -The regex in a `livecheck` block is used within a strategy to restrict matching to only relevant text (or strings) and to establish what part of the matched text is the version (using a capture group). +* **Use `\.t` in place of `\.tgz`, `\.tar\.gz`, etc.** There are a variety of different file extensions for tarballs (e.g. `.tar.bz2`, `tbz2`, `.tar.gz`, `.tgz`, `.tar.xz`, `.txz`, etc.) and the upstream source may switch from one compression format to another over time. `\.t` avoids this issue by matching current and future formats starting with `t`. Outside of tarballs, we use the full file extension in the regex like `\.zip`, `\.jar`, etc. -Creating a good regex is a balance between being too strict (breaking easily) and too loose (matching more than it should). +## Example `livecheck` blocks -* For technical reasons, **the `regex` call in the `livecheck` block should always use parentheses** (e.g. `regex(/example/)`). +The following examples cover a number of patterns that you may encounter. These are intended to be representative samples and can be easily adapted. -* **Regex literals should follow the established Homebrew style**, where the `/.../` syntax is the default and the `%r{...}` syntax is used when a forward slash (`/`) is present. +When in doubt, start with one of these examples instead of copy-pasting a `livecheck` block from a random formula/cask. -* **Regexes should adequately represent their intention.** This requires an understanding of basic regex syntax, so we avoid issues like using `.` (match any character) instead of `\.` when we only want to match a period. We also try to be careful about our use of generic catch-alls like `.*` or `.+`, as it's often better to use something non-greedy and contextually appropriate. For example, if we wanted to match a variety of characters while trying to stay within the bounds of an HTML attribute, we could use something like `[^"' >]*?`. +### File names -* **Try not to be too specific in some parts of the regex.** For example, if a file name uses a hyphen (`-`) between the software name and version (e.g. `example-1.2.3.tar.gz`), we may want to use something like `example[._-]v?(\d+(?:\.\d+)+)\.t` instead. This would allow the regex to continue matching if the upstream file name format changes to `example.1.2.3.tar.gz` or `example_1.2.3.tar.gz`. +```ruby + livecheck do + url "https://www.example.com/downloads/" + regex(/href=.*?example[._-]v?(\d+(?:\.\d+)+)\.t/i) + end +``` -* **Regexes should be case insensitive unless case sensitivity is explicitly required for matching to work properly**. Case insensitivity is enabled by adding the `i` flag at the end of the regex literal (e.g. `/.../i` or `%r{...}i`). This helps to improve reliability and reduce maintenance, as a case-insensitive regex doesn't need to be manually updated if there are any upstream changes in letter case. +When matching the version from a file name on an HTML page, we often restrict matching to `href` attributes. `href=.*?` will match the opening delimiter (`"`, `'`) as well as any part of the URL before the file name. -* **Regexes should only use a capturing group around the part of the matched text that corresponds to the version**. For example, in `/href=.*?example-v?(\d+(?:\.\d+)+)(?:-src)?\.t/i`, we're only using a capturing group around the version part (matching a version like `1.2`, `1.2.3`, etc.) and we're using non-capturing groups elsewhere (e.g. `(?:-src)?`). This allows livecheck to rely on the first capture group being the version string. +We sometimes make this more explicit to exclude unwanted matches. URLs with a preceding path can use `href=.*?/` and others can use `href=["']?`. For example, this is necessary when the page also contains unwanted files with a longer prefix (`another-example-1.2.tar.gz`). -* **Regexes should only match stable versions**. Regexes should be written to avoid prerelease versions like `1.2-alpha1`, `1.2-beta1`, `1.2-rc1`, etc. +### Version directories -* **Restrict matching to `href` attributes when targeting file names in an HTML page (or `url` attributes in an RSS feed)**. Using `href=.*?` (or `url=.*?`) at the start of the regex will take care of any opening delimiter for the attribute (`"`, `'`, or nothing) as well as any leading part of the URL. This helps to keep the regex from being overly specific, reducing the need for maintenance in the future. A regex like `href=.*?example-...` is often fine but sometimes it's necessary to have something explicit before the file name to limit matching to only what's appropriate (e.g. `href=.*?/example-...` or `href=["']?example-...`). Similarly, `["' >]` can be used to target the end of the attribute, when needed. +```ruby + livecheck do + url "https://www.example.com/releases/example/" + regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i) + end +``` -* **Use `\.t` in place of `\.tgz`, `\.tar\.gz`, etc.** There are a number of different file extensions for tarballs (e.g. `.tar.bz2`, `tbz2`, `.tar.gz`, `.tgz`, `.tar.xz`, `.txz`, etc.) and the upstream source may switch from one compression format to another over time. `\.t` avoids this issue by matching current and future formats starting with `t`. Outside of tarballs, it's fine to use full file extensions in the regex like `\.zip`, `\.jar`, etc. +When checking a directory listing page, sometimes files are separated into version directories (e.g. `1.2.3/`). In this case, we must identify versions from the directory names. -* **When matching versions like `1.2`, `1.2.3`, `v1.2`, etc., use the standard snippet for this in the regex: `v?(\d+(?:\.\d+)+)`**. This is often copy-pasted into the regex but it can also be modified to suit the circumstances. For example, if the version uses underscores instead, the standard regex could be modified to something like `v?(\d+(?:[._]\d+)+)`. [The general idea behind this standard snippet is that it better represents our intention compared to older, looser snippets that we now avoid (e.g. `[0-9.]+`).] +### Git tags -* **Similarly, when matching Git tags with a version like `1.2`, `1.2.3`, `v1.2.3`, etc., start with the standard regex for this (`/^v?(\d+(?:\.\d+)+)$/i`) and modify it as needed**. Sometimes it's necessary to modify the regex to add a prefix, like `/^example-v?(\d+(?:\.\d+)+)$/i` for an `example-1.2.3` tag format. The general idea here is that Git tags are strings, so we can avoid unrelated software by restricting the start of the string (`^`) and unstable versions by restricting the end of the string (`$`). +```ruby + livecheck do + url :stable + regex(/^v?(\d+(?:\.\d+)+)$/i) + end +``` -## Built-in strategies +When the `stable` URL uses the `Git` strategy, the regex above will only match tags like `1.2`/`v1.2`, etc. -Livecheck's strategies are established methods for finding versions at either a specific source or a general type of source. The available strategies are as follows: +If tags include the software name as a prefix (e.g. `example-1.2.3`), it's easy to modify the regex accordingly: `/^example[._-]v?(\d+(?:\.\d+)+)$/i` -* `Apache` -* `Bitbucket` -* `Git` -* `Gnome` -* `Gnu` -* `Hackage` -* `Launchpad` -* `Npm` -* `PageMatch` -* `Pypi` -* `Sourceforge` +### `PageMatch` `strategy` block + +```ruby + livecheck do + url :homepage + regex(/href=.*?example[._-]v?(\d{4}-\d{2}-\d{2})\.t/i) + strategy :page_match do |page, regex| + page.scan(regex).map { |match| match&.first&.gsub(/\D/, "") } + end + end +``` -Each strategy has a `#match?(url)` method which determines whether the strategy can be applied to the provided URL. The `PageMatch` strategy is used as a fallback when a regex is provided and no other strategies apply. `PageMatch` simply uses the regex to match content on a page, so it's the desired strategy for URLs where a more-specific strategy doesn't apply. +When necessary, a `strategy` block allows us to have greater flexibility in how upstream version information is matched and processed. Currently, they're only used when the upstream version format needs to be manipulated to match the formula/cask format. In the example above, we're converting a date format like `2020-01-01` into `20200101`. -Some of the strategies generate a URL and regex internally. In these cases, the strategy often derives information from the provided URL and uses it to create the URL it will check and the regex used for matching. However, if a `regex` is provided in the `livecheck` block, it will be used instead of any generated regex. +The `PageMatch` `strategy` block style seen here also applies to any strategy that uses `PageMatch` internally. -Livecheck also has a simple numeric priority system, where 5 is the default unless a strategy has defined its own `PRIORITY` constant. Currently, the `Git` strategy has a higher priority (8) and the `PageMatch` strategy has a low priority (0). In practice, this means that when more than one strategy applies to a URL (usually a specific strategy and `PageMatch`), the higher priority strategy is the one that's used. +### `Git` `strategy` block -### Tap strategies +```ruby + livecheck do + url :stable + regex(/^(\d{4}-\d{2}-\d{2})$/i) + strategy :git do |tags, regex| + tags.map { |tag| tag[regex, 1]&.gsub(/\D/, "") }.compact + end + end +``` -Taps can add strategies to apply to their formulae by creating a `livecheck_strategy` folder in the root directory and placing strategy files within. At a minimum, strategies must provide a `#match?(url)` method and a `#find_versions(url, regex)` method. +A `strategy` block for `Git` is a bit different, as the block receives an array of tag strings instead of a page content string. Similar to the `PageMatch` example, this is converting tags with a date format like `2020-01-01` into `20200101`. -The `#match?(url)` method takes a URL string and returns `true` or `false` to indicate whether the strategy can be applied to the URL. +### Skip -`#find_versions(url, regex)` takes a URL and an optional regex and returns a `Hash` with a format like `{ :matches => {}, :regex => regex, :url => url }`. The `:matches` `Hash` uses version strings as the keys (e.g. `"1.2.3"`) and `Version` objects as the values. `:regex` is either the strategy-generated regex (if applicable), the regex provided as an argument, or `nil`. The `:url` is either the strategy-generated URL (if applicable) or the original URL provided. +```ruby + livecheck do + skip "No version information available" + end +``` -The built-in strategies in Homebrew's `livecheck_strategy` folder may serve as examples to follow when creating tap strategies. Many of the built-in strategies simply generate a URL and regex before using the `PageMatch` strategy to do the heavy lifting (e.g. `PageMatch.find_versions(page_url, regex)`). When a strategy is checking a text page of some sort (e.g. HTML, RSS, etc.), it may be able to do the same thing. If a strategy needs to do something more complex, the `Git` and `PageMatch` strategies can be referenced as standalone examples. +Livecheck automatically skips some formulae/casks for a number of reasons (deprecated, disabled, discontinued, etc.). However, on rare occasions we need to use a `livecheck` block to do a manual skip. The `skip` method takes a string containing a very brief reason for skipping.
true
Other
Homebrew
brew
308390ba5b7fe03e5ed899c70e49faa47044ace8.json
Address feedback and expand documentation Co-authored-by: Mike McQuaid <mike@mikemcquaid.com> Co-authored-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
docs/Formula-Cookbook.md
@@ -545,6 +545,19 @@ Instead of `git diff | pbcopy`, for some editors `git diff >> path/to/your/formu If anything isn’t clear, you can usually figure it out by `grep`ping the `$(brew --repo homebrew/core)` directory. Please submit a pull request to amend this document if you think it will help! +### `livecheck` blocks + +When `brew livecheck` is unable to identify versions for a formula, we can control its behavior using a `livecheck` block. Here is a simple example to check a page for links containing a filename like `example-1.2.tar.gz`: + +```ruby +livecheck do + url "https://www.example.com/downloads/" + regex(/href=.*?example[._-]v?(\d+(?:\.\d+)+)\.t/i) +end +``` + +For `url`/`regex` guidelines and additional `livecheck` block examples, refer to the [`brew livecheck` documentation](Brew-Livecheck.md). For more technical information on the methods used in a `livecheck` block, please refer to the [`Livecheck` class documentation](https://rubydoc.brew.sh/Livecheck.html). + ### Unstable versions (`head`) Formulae can specify an alternate download for the upstream project’s [`head`](https://rubydoc.brew.sh/Formula#head-class_method) (`master`/`trunk`).
true
Other
Homebrew
brew
308390ba5b7fe03e5ed899c70e49faa47044ace8.json
Address feedback and expand documentation Co-authored-by: Mike McQuaid <mike@mikemcquaid.com> Co-authored-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
docs/README.md
@@ -43,7 +43,7 @@ - [Deprecating, Disabling, and Removing Formulae](Deprecating-Disabling-and-Removing-Formulae.md) - [Node for Formula Authors](Node-for-Formula-Authors.md) - [Python for Formula Authors](Python-for-Formula-Authors.md) -- [Brew Livecheck](Brew-Livecheck.md) +- [`brew livecheck`](Brew-Livecheck.md) - [Migrating A Formula To A Tap](Migrating-A-Formula-To-A-Tap.md) - [Rename A Formula](Rename-A-Formula.md) - [Building Against Non-Homebrew Dependencies](Building-Against-Non-Homebrew-Dependencies.md)
true
Other
Homebrew
brew
94f900ea87f30461730ce3ca0065ef582e180c29.json
docs: add brew livecheck documentation
docs/Brew-Livecheck.md
@@ -0,0 +1,115 @@ +# Brew Livecheck + +**NOTE: This document is a work in progress and will be revised and expanded as time permits.** + +**NOTE: `livecheck` blocks are currently found in separate files in the [Homebrew/homebrew-livecheck](https://github.com/Homebrew/homebrew-livecheck) repository's `Livecheckables` folder. These will be migrated to their respective formulae in Homebrew/homebrew-core in the near future and this document is written as if this migration has already happened.** + +The general purpose of the `brew livecheck` command is to find the newest version of a formula's software by checking an upstream source. Livecheck has [built-in strategies](#built-in-strategies) that can identify versions from some popular sources, such as Git repositories, certain websites, etc. + +## Default behavior + +When livecheck isn't given instructions for how to check for upstream versions of a formula's software, it does the following by default: + +1. Collect the `head`, `stable`, and `homepage` URLs from the formula, in that order. +2. Determine if any of the available strategies can be applied to the first URL. Move on to the next URL if no strategies apply. +3. If a strategy can be applied, use it to check for new versions. +4. Return the newest version (or an error if versions could not be found at any available URLs). + +This approach works fine for a number of formulae without requiring any manual intervention. However, it's sometimes necessary to change livecheck's default behavior to create a working check for a formula. + +It may be that the source livecheck is using doesn't provide the newest version and we need to check a different one instead. In another case, livecheck may be matching a version it shouldn't and we need to provide a regex to only match what's appropriate. + +## The `livecheck` block + +We can control livecheck's behavior by providing a `livecheck` block in the formula. Here is a simple example to check a "downloads" page for links containing a filename like `example-1.2.tar.gz`: + +```ruby +livecheck do + url "https://www.example.com/downloads/" + regex(/href=.*?example[._-]v?(\d+(?:\.\d+)+)\.t/i) +end +``` + +At the moment, it's only necessary to create a `livecheck` block in a formula when the default check doesn't work properly. + +## Creating a check + +1. **Use the debug output to understand the current situation**. Running `brew livecheck --debug <formula>` (where `<formula>` is the formula name) will provide more information about which URL livecheck is using and any strategy that applies. + +2. **Research available sources**. It's generally preferable to check for a new version at the same source as the `stable` URL, when possible. With this in mind, it may be a good idea to start by removing the file name from the `stable` URL, to see if this is a directory listing page. If that doesn't work, the website may have a downloads page we can check for versions. If it's not possible to find the newest version at this source through any means, try checking other sources from the formula (e.g. an upstream Git repository or the homepage). It's also sometimes necessary to search for other sources outside of the formula. + +3. **Compare available versions between sources**. If the latest version is available from the `stable` source, it's best to use that. Otherwise, check the other sources to identify where the latest version is available. + +4. **Select a source**. After researching and comparing sources, decide which one is the best available option and use it as the `url` in the `livecheck` block. + +5. **Create a regex, if necessary or beneficial**. If the check works fine without a regex and wouldn't benefit from having one, it's fine to omit it. However, when a default check isn't working properly and we need to create a `livecheck` block, a regex is almost always necessary as well. More information on creating regexes can be found in the [regex guidelines](#regex-guidelines) section. + +6. **Verify the check is working as intended**. Run `brew livecheck --debug <formula>` again to ensure livecheck is identifying all the versions it should and properly returning the newest version at the end. + +### URL guidelines + +* **A `url` is a required part of a `livecheck` block** and can either be a string containing a URL (e.g. `"https://www.example.com/downloads/"`) or a symbol referencing one of the supported formula URLs (i.e. `:stable`, `:homepage`, or `:head`). + +* **Use a symbol for a formula URL (i.e. `:homepage`, `:stable`, and `:head`) when appropriate**, to avoid duplicating formula URLs in the livecheckable. + +* **It's generally preferable to check for versions in the same location as the stable archive, when possible**. This preference is stronger for first-party sources (websites, repositories, etc.) and becomes weaker for third-party sources (e.g. mirrors, another software package manager, etc.). + +### Regex guidelines + +The regex in a `livecheck` block is used within a strategy to restrict matching to only relevant text (or strings) and to establish what part of the matched text is the version (using a capture group). + +Creating a good regex is a balance between being too strict (breaking easily) and too loose (matching more than it should). + +* For technical reasons, **the `regex` call in the `livecheck` block should always use parentheses** (e.g. `regex(/example/)`). + +* **Regex literals should follow the established Homebrew style**, where the `/.../` syntax is the default and the `%r{...}` syntax is used when a forward slash (`/`) is present. + +* **Regexes should adequately represent their intention.** This requires an understanding of basic regex syntax, so we avoid issues like using `.` (match any character) instead of `\.` when we only want to match a period. We also try to be careful about our use of generic catch-alls like `.*` or `.+`, as it's often better to use something non-greedy and contextually appropriate. For example, if we wanted to match a variety of characters while trying to stay within the bounds of an HTML attribute, we could use something like `[^"' >]*?`. + +* **Try not to be too specific in some parts of the regex.** For example, if a file name uses a hyphen (`-`) between the software name and version (e.g. `example-1.2.3.tar.gz`), we may want to use something like `example[._-]v?(\d+(?:\.\d+)+)\.t` instead. This would allow the regex to continue matching if the upstream file name format changes to `example.1.2.3.tar.gz` or `example_1.2.3.tar.gz`. + +* **Regexes should be case insensitive unless case sensitivity is explicitly required for matching to work properly**. Case insensitivity is enabled by adding the `i` flag at the end of the regex literal (e.g. `/.../i` or `%r{...}i`). This helps to improve reliability and reduce maintenance, as a case-insensitive regex doesn't need to be manually updated if there are any upstream changes in letter case. + +* **Regexes should only use a capturing group around the part of the matched text that corresponds to the version**. For example, in `/href=.*?example-v?(\d+(?:\.\d+)+)(?:-src)?\.t/i`, we're only using a capturing group around the version part (matching a version like `1.2`, `1.2.3`, etc.) and we're using non-capturing groups elsewhere (e.g. `(?:-src)?`). This allows livecheck to rely on the first capture group being the version string. + +* **Regexes should only match stable versions**. Regexes should be written to avoid prerelease versions like `1.2-alpha1`, `1.2-beta1`, `1.2-rc1`, etc. + +* **Restrict matching to `href` attributes when targeting file names in an HTML page (or `url` attributes in an RSS feed)**. Using `href=.*?` (or `url=.*?`) at the start of the regex will take care of any opening delimiter for the attribute (`"`, `'`, or nothing) as well as any leading part of the URL. This helps to keep the regex from being overly specific, reducing the need for maintenance in the future. A regex like `href=.*?example-...` is often fine but sometimes it's necessary to have something explicit before the file name to limit matching to only what's appropriate (e.g. `href=.*?/example-...` or `href=["']?example-...`). Similarly, `["' >]` can be used to target the end of the attribute, when needed. + +* **Use `\.t` in place of `\.tgz`, `\.tar\.gz`, etc.** There are a number of different file extensions for tarballs (e.g. `.tar.bz2`, `tbz2`, `.tar.gz`, `.tgz`, `.tar.xz`, `.txz`, etc.) and the upstream source may switch from one compression format to another over time. `\.t` avoids this issue by matching current and future formats starting with `t`. Outside of tarballs, it's fine to use full file extensions in the regex like `\.zip`, `\.jar`, etc. + +* **When matching versions like `1.2`, `1.2.3`, `v1.2`, etc., use the standard snippet for this in the regex: `v?(\d+(?:\.\d+)+)`**. This is often copy-pasted into the regex but it can also be modified to suit the circumstances. For example, if the version uses underscores instead, the standard regex could be modified to something like `v?(\d+(?:[._]\d+)+)`. [The general idea behind this standard snippet is that it better represents our intention compared to older, looser snippets that we now avoid (e.g. `[0-9.]+`).] + +* **Similarly, when matching Git tags with a version like `1.2`, `1.2.3`, `v1.2.3`, etc., start with the standard regex for this (`/^v?(\d+(?:\.\d+)+)$/i`) and modify it as needed**. Sometimes it's necessary to modify the regex to add a prefix, like `/^example-v?(\d+(?:\.\d+)+)$/i` for an `example-1.2.3` tag format. The general idea here is that Git tags are strings, so we can avoid unrelated software by restricting the start of the string (`^`) and unstable versions by restricting the end of the string (`$`). + +## Built-in strategies + +Livecheck's strategies are established methods for finding versions at either a specific source or a general type of source. The available strategies are as follows: + +* `Apache` +* `Bitbucket` +* `Git` +* `Gnome` +* `Gnu` +* `Hackage` +* `Launchpad` +* `Npm` +* `PageMatch` +* `Pypi` +* `Sourceforge` + +Each strategy has a `#match?(url)` method which determines whether the strategy can be applied to the provided URL. The `PageMatch` strategy is used as a fallback when a regex is provided and no other strategies apply. `PageMatch` simply uses the regex to match content on a page, so it's the desired strategy for URLs where a more-specific strategy doesn't apply. + +Some of the strategies generate a URL and regex internally. In these cases, the strategy often derives information from the provided URL and uses it to create the URL it will check and the regex used for matching. However, if a `regex` is provided in the `livecheck` block, it will be used instead of any generated regex. + +Livecheck also has a simple numeric priority system, where 5 is the default unless a strategy has defined its own `PRIORITY` constant. Currently, the `Git` strategy has a higher priority (8) and the `PageMatch` strategy has a low priority (0). In practice, this means that when more than one strategy applies to a URL (usually a specific strategy and `PageMatch`), the higher priority strategy is the one that's used. + +### Tap strategies + +Taps can add strategies to apply to their formulae by creating a `livecheck_strategy` folder in the root directory and placing strategy files within. At a minimum, strategies must provide a `#match?(url)` method and a `#find_versions(url, regex)` method. + +The `#match?(url)` method takes a URL string and returns `true` or `false` to indicate whether the strategy can be applied to the URL. + +`#find_versions(url, regex)` takes a URL and an optional regex and returns a `Hash` with a format like `{ :matches => {}, :regex => regex, :url => url }`. The `:matches` `Hash` uses version strings as the keys (e.g. `"1.2.3"`) and `Version` objects as the values. `:regex` is either the strategy-generated regex (if applicable), the regex provided as an argument, or `nil`. The `:url` is either the strategy-generated URL (if applicable) or the original URL provided. + +The built-in strategies in Homebrew's `livecheck_strategy` folder may serve as examples to follow when creating tap strategies. Many of the built-in strategies simply generate a URL and regex before using the `PageMatch` strategy to do the heavy lifting (e.g. `PageMatch.find_versions(page_url, regex)`). When a strategy is checking a text page of some sort (e.g. HTML, RSS, etc.), it may be able to do the same thing. If a strategy needs to do something more complex, the `Git` and `PageMatch` strategies can be referenced as standalone examples.
true
Other
Homebrew
brew
94f900ea87f30461730ce3ca0065ef582e180c29.json
docs: add brew livecheck documentation
docs/README.md
@@ -43,6 +43,7 @@ - [Deprecating, Disabling, and Removing Formulae](Deprecating-Disabling-and-Removing-Formulae.md) - [Node for Formula Authors](Node-for-Formula-Authors.md) - [Python for Formula Authors](Python-for-Formula-Authors.md) +- [Brew Livecheck](Brew-Livecheck.md) - [Migrating A Formula To A Tap](Migrating-A-Formula-To-A-Tap.md) - [Rename A Formula](Rename-A-Formula.md) - [Building Against Non-Homebrew Dependencies](Building-Against-Non-Homebrew-Dependencies.md)
true
Other
Homebrew
brew
e7b369273a9b23f0674491fe33a8d3aaf197c292.json
completions: link official taps automatically
Library/Homebrew/cmd/update-report.rb
@@ -8,7 +8,6 @@ require "cleanup" require "description_cache_store" require "cli/parser" -require "completions" module Homebrew extend T::Sig @@ -151,15 +150,6 @@ def update_report puts "Already up-to-date." unless args.quiet? end - if Completions.read_completions_option.empty? - ohai "Homebrew completions are unlinked by default!" - puts <<~EOS - To opt-in to automatically linking Homebrew shell competion files, run: - brew completions link - Then, follow the directions at #{Formatter.url("https://docs.brew.sh/Shell-Completion")} - EOS - end - Commands.rebuild_commands_completion_list link_completions_manpages_and_docs Tap.each(&:link_completions_and_manpages) @@ -198,8 +188,7 @@ def install_core_tap_if_necessary def link_completions_manpages_and_docs(repository = HOMEBREW_REPOSITORY) command = "brew update" - - Completions.link_if_allowed! command: command + Utils::Link.link_completions(repository, command) Utils::Link.link_manpages(repository, command) Utils::Link.link_docs(repository, command) rescue => e
true
Other
Homebrew
brew
e7b369273a9b23f0674491fe33a8d3aaf197c292.json
completions: link official taps automatically
Library/Homebrew/completions.rb
@@ -11,43 +11,69 @@ module Completions module_function - sig { params(command: String).void } - def link_if_allowed!(command: "brew completions link") - if link_completions? - link! command: command - else - unlink! - end - end - - sig { params(command: String).void } - def link!(command: "brew completions link") + sig { void } + def link! write_completions_option "yes" - Utils::Link.link_completions HOMEBREW_REPOSITORY, command + Tap.each do |tap| + Utils::Link.link_completions tap.path, "brew completions link" + end end sig { void } def unlink! write_completions_option "no" - Utils::Link.unlink_completions HOMEBREW_REPOSITORY + Tap.each do |tap| + next if tap.official? + + Utils::Link.unlink_completions tap.path + end end sig { returns(T::Boolean) } def link_completions? read_completions_option == "yes" end - sig { returns(String) } - def read_completions_option + sig { returns(T::Boolean) } + def completions_to_link? + shells = %w[bash fish zsh] + Tap.each do |tap| + next if tap.official? + + shells.each do |shell| + return true if (tap.path/"completions/#{shell}").exist? + end + end + + false + end + + sig { params(option: String).returns(String) } + def read_completions_option(option: "linkcompletions") HOMEBREW_REPOSITORY.cd do - Utils.popen_read("git", "config", "--get", "homebrew.linkcompletions").chomp + Utils.popen_read("git", "config", "--get", "homebrew.#{option}").chomp end end - sig { params(state: String).void } - def write_completions_option(state) + sig { params(state: String, option: String).void } + def write_completions_option(state, option: "linkcompletions") HOMEBREW_REPOSITORY.cd do - T.unsafe(self).safe_system "git", "config", "--replace-all", "homebrew.linkcompletions", state.to_s + T.unsafe(self).safe_system "git", "config", "--replace-all", "homebrew.#{option}", state.to_s end end + + sig { void } + def show_completions_message_if_needed + return if read_completions_option(option: "completionsmessageshown") == "yes" + return unless completions_to_link? + + T.unsafe(self).ohai "Homebrew completions for external commands are unlinked by default!" + T.unsafe(self).puts <<~EOS + To opt-in to automatically linking Homebrew shell competion files, run: + brew completions link + Then, follow the directions at #{Formatter.url("https://docs.brew.sh/Shell-Completion")} + EOS + + write_completions_option("yes", option: "completionsmessageshown") + end end
true
Other
Homebrew
brew
e7b369273a9b23f0674491fe33a8d3aaf197c292.json
completions: link official taps automatically
Library/Homebrew/tap.rb
@@ -2,6 +2,7 @@ # frozen_string_literal: true require "commands" +require "completions" require "extend/cachable" require "description_cache_store" @@ -340,7 +341,13 @@ def install(full_clone: true, quiet: false, clone_target: nil, force_auto_update def link_completions_and_manpages command = "brew tap --repair" Utils::Link.link_manpages(path, command) - Utils::Link.link_completions(path, command) + + Completions.show_completions_message_if_needed + if official? || Completions.link_completions? + Utils::Link.link_completions(path, command) + else + Utils::Link.unlink_completions(path) + end end # Uninstall this {Tap}.
true
Other
Homebrew
brew
e7b369273a9b23f0674491fe33a8d3aaf197c292.json
completions: link official taps automatically
Library/Homebrew/test/cmd/completions_spec.rb
@@ -18,11 +18,5 @@ .to output(/Completions are linked/).to_stdout .and not_to_output.to_stderr .and be_a_success - - brew "completions", "unlink" - expect { brew "completions" } - .to output(/Completions are not linked/).to_stdout - .and not_to_output.to_stderr - .and be_a_success end end
true
Other
Homebrew
brew
e7b369273a9b23f0674491fe33a8d3aaf197c292.json
completions: link official taps automatically
Library/Homebrew/test/tap_spec.rb
@@ -88,6 +88,7 @@ def setup_completion(link:) HOMEBREW_REPOSITORY.cd do system "git", "init" system "git", "config", "--replace-all", "homebrew.linkcompletions", link + system "git", "config", "--replace-all", "homebrew.completionsmessageshown", "yes" end end @@ -316,11 +317,11 @@ def setup_completion(link:) (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? end - specify "#link_completions_and_manpages when completions are enabled" do + specify "#link_completions_and_manpages when completions are enabled for non-official tap" do setup_tap_files setup_git_repo setup_completion link: "yes" - tap = described_class.new("Homebrew", "baz") + tap = described_class.new("NotHomebrew", "baz") tap.install clone_target: subject.path/".git" (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete (HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete @@ -337,11 +338,11 @@ def setup_completion(link:) (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? end - specify "#link_completions_and_manpages when completions are disabled" do + specify "#link_completions_and_manpages when completions are disabled for non-official tap" do setup_tap_files setup_git_repo setup_completion link: "no" - tap = described_class.new("Homebrew", "baz") + tap = described_class.new("NotHomebrew", "baz") tap.install clone_target: subject.path/".git" (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete tap.link_completions_and_manpages @@ -355,6 +356,27 @@ def setup_completion(link:) (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? end + specify "#link_completions_and_manpages when completions are enabled for official tap" do + setup_tap_files + setup_git_repo + setup_completion link: "no" + tap = described_class.new("Homebrew", "baz") + tap.install clone_target: subject.path/".git" + (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete + (HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete + (HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete + (HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete + tap.link_completions_and_manpages + expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file + expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file + expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file + expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file + tap.uninstall + ensure + (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist? + (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? + end + specify "#config" do setup_git_repo
true
Other
Homebrew
brew
e7b369273a9b23f0674491fe33a8d3aaf197c292.json
completions: link official taps automatically
Library/Homebrew/utils/link.rb
@@ -1,8 +1,6 @@ # typed: true # frozen_string_literal: true -require "completions" - module Utils # Helper functions for creating symlinks. # @@ -66,11 +64,6 @@ def unlink_manpages(path) end def link_completions(path, command) - unless Completions.link_completions? - unlink_completions path - return - end - link_src_dst_dirs(path/"completions/bash", HOMEBREW_PREFIX/"etc/bash_completion.d", command) link_src_dst_dirs(path/"completions/zsh", HOMEBREW_PREFIX/"share/zsh/site-functions", command) link_src_dst_dirs(path/"completions/fish", HOMEBREW_PREFIX/"share/fish/vendor_completions.d", command)
true
Other
Homebrew
brew
e7b369273a9b23f0674491fe33a8d3aaf197c292.json
completions: link official taps automatically
docs/Shell-Completion.md
@@ -4,10 +4,10 @@ Homebrew comes with completion definitions for the `brew` command. Some packages `zsh`, `bash` and `fish` are currently supported. -Shell completions for built-in Homebrew commands are not automatically installed. To opt-in to using our completions, they need to be linked to `HOMEBREW_PREFIX` by running `brew completions link`. - You must then configure your shell to enable its completion support. This is because the Homebrew-managed completions are stored under `HOMEBREW_PREFIX` which your system shell may not be aware of, and since it is difficult to automatically configure `bash` and `zsh` completions in a robust manner, the Homebrew installer does not do it for you. +Shell completions for external Homebrew commands are not automatically installed. To opt-in to using completions for external commands (if provided), they need to be linked to `HOMEBREW_PREFIX` by running `brew completions link`. + ## Configuring Completions in `bash` To make Homebrew's completions available in `bash`, you must source the definitions as part of your shell's startup. Add the following to your `~/.bash_profile` (or, if it doesn't exist, `~/.profile`):
true
Other
Homebrew
brew
c56fff39280b6d059f72cdf999f93d705d045c10.json
cmd/prof: raise error when cmd is bash file
Library/Homebrew/brew.rb
@@ -131,8 +131,6 @@ class MissingEnvironmentVariables < RuntimeError; end end exec "brew-#{cmd}", *ARGV else - raise "command made by bash not ruby: #{cmd}" if Commands.only_bash_command_list.include?(cmd) - possible_tap = OFFICIAL_CMD_TAPS.find { |_, cmds| cmds.include?(cmd) } possible_tap = Tap.fetch(possible_tap.first) if possible_tap
true
Other
Homebrew
brew
c56fff39280b6d059f72cdf999f93d705d045c10.json
cmd/prof: raise error when cmd is bash file
Library/Homebrew/commands.rb
@@ -197,8 +197,4 @@ def rebuild_commands_completion_list file = HOMEBREW_CACHE/"all_commands_list.txt" file.atomic_write("#{commands(aliases: true).sort.join("\n")}\n") end - - def only_bash_command_list - internal_commands.reject { |cmd| valid_internal_cmd?(cmd) } - end end
true
Other
Homebrew
brew
c56fff39280b6d059f72cdf999f93d705d045c10.json
cmd/prof: raise error when cmd is bash file
Library/Homebrew/dev-cmd/prof.rb
@@ -26,6 +26,8 @@ def prof brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path FileUtils.mkdir_p "prof" + cmd = args.named.first + raise UsageError, "#{cmd} is a Bash command!" if Commands.path(cmd).extname == ".sh" if args.stackprof? Homebrew.install_gem_setup_path! "stackprof"
true
Other
Homebrew
brew
9f9903f80de9f9701ef7dec4b52e0cf93890bc90.json
Publish API for `Stdenv`. `@private` hides classes from documentation altogether, while `@api private` merely marks it as a private API.
Library/Homebrew/extend/ENV/std.rb
@@ -4,7 +4,7 @@ require "hardware" require "extend/ENV/shared" -# @private +# @api private module Stdenv extend T::Sig
false
Other
Homebrew
brew
ce45868973620a1fed4505e0fc9c2f9a928bdff0.json
Improve documentation and add type signatures.
Library/Homebrew/formula.rb
@@ -67,15 +67,6 @@ class Formula extend Predicable # @!method inreplace(paths, before = nil, after = nil) - # Actually implemented in {Utils::Inreplace.inreplace}. - # Sometimes we have to change a bit before we install. Mostly we - # prefer a patch but if you need the `prefix` of this formula in the - # patch you have to resort to `inreplace`, because in the patch - # you don't have access to any variable defined by the formula. Only - # `HOMEBREW_PREFIX` is available in the embedded patch. - # - # `inreplace` supports regular expressions: - # <pre>inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool"</pre> # @see Utils::Inreplace.inreplace # The name of this {Formula}. @@ -590,6 +581,7 @@ def prefix_linked?(v = pkg_version) end # {PkgVersion} of the linked keg for the formula. + sig { returns(T.nilable(PkgVersion)) } def linked_version return unless linked? @@ -668,9 +660,12 @@ def lib # The directory where the formula's binaries should be installed. # This is not symlinked into `HOMEBREW_PREFIX`. - # It is also commonly used to install files that we do not wish to be + # It is commonly used to install files that we do not wish to be # symlinked into `HOMEBREW_PREFIX` from one of the other directories and # instead manually create symlinks or wrapper scripts into e.g. {#bin}. + # <pre>libexec.install "foo.jar" + # bin.write_jar_script libexec/"foo.jar", "foo" + # </pre> def libexec prefix/"libexec" end @@ -1104,26 +1099,17 @@ def keg_only? # @private delegate keg_only_reason: :"self.class" - # sometimes the formula cleaner breaks things - # skip cleaning paths in a formula with a class method like this: - # skip_clean "bin/foo", "lib/bar" - # keep .la files with: - # skip_clean :la + # @see .skip_clean # @private sig { params(path: Pathname).returns(T::Boolean) } - def skip_clean?(path) return true if path.extname == ".la" && self.class.skip_clean_paths.include?(:la) to_check = path.relative_path_from(prefix).to_s self.class.skip_clean_paths.include? to_check end - # Sometimes we accidentally install files outside prefix. After we fix that, - # users will get nasty link conflict error. So we create an allowlist here to - # allow overwriting certain files. e.g. - # link_overwrite "bin/foo", "lib/bar" - # link_overwrite "share/man/man1/baz-*" + # @see .link_overwrite # @private def link_overwrite?(path) # Don't overwrite files not created by Homebrew. @@ -1163,36 +1149,42 @@ def link_overwrite?(path) # Defaults to false. # @!method deprecated? # @return [Boolean] + # @see .deprecate! delegate deprecated?: :"self.class" # The date that this {Formula} was or becomes deprecated. # Returns `nil` if no date is specified. # @!method deprecation_date # @return Date + # @see .deprecate! delegate deprecation_date: :"self.class" # The reason this {Formula} is deprecated. # Returns `nil` if no reason is specified or the formula is not deprecated. # @!method deprecation_reason # @return [String, Symbol] + # @see .deprecate! delegate deprecation_reason: :"self.class" # Whether this {Formula} is disabled (i.e. cannot be installed). # Defaults to false. # @!method disabled? # @return [Boolean] + # @see .disable! delegate disabled?: :"self.class" # The date that this {Formula} was or becomes disabled. # Returns `nil` if no date is specified. # @!method disable_date # @return Date + # @see .disable! delegate disable_date: :"self.class" # The reason this {Formula} is disabled. # Returns `nil` if no reason is specified or the formula is not disabled. # @!method disable_reason # @return [String, Symbol] + # @see .disable! delegate disable_reason: :"self.class" sig { returns(T::Boolean) } @@ -1406,21 +1398,22 @@ def inspect end # Standard parameters for configure builds. + sig { returns(T::Array[String]) } def std_configure_args ["--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}", "--libdir=#{lib}"] end # Standard parameters for cargo builds. + sig { returns(T::Array[T.any(String, Pathname)]) } def std_cargo_args ["--locked", "--root", prefix, "--path", "."] end # Standard parameters for CMake builds. + # # Setting `CMAKE_FIND_FRAMEWORK` to "LAST" tells CMake to search for our # libraries before trying to utilize Frameworks, many of which will be from # 3rd party installs. - # Note that there isn't a std_autotools variant because autotools is a lot - # less consistent and the standard parameters are more memorable. sig { returns(T::Array[String]) } def std_cmake_args args = %W[ @@ -1445,6 +1438,7 @@ def std_cmake_args end # Standard parameters for Go builds. + sig { returns(T::Array[T.any(String, Pathname)]) } def std_go_args ["-trimpath", "-o", bin/name] end @@ -1469,6 +1463,20 @@ def std_meson_args ["--prefix=#{prefix}", "--libdir=#{lib}", "--buildtype=release", "--wrap-mode=nofallback"] end + # Shared library names according to platform conventions. + # + # Optionally specify a `version` to restrict the shared library to a specific + # version. The special string "*" matches any version. + # + # If `name` is specified as "*", match any shared library of any version. + # + # <pre> + # shared_library("foo") #=> foo.dylib + # shared_library("foo", 1) #=> foo.1.dylib + # shared_library("foo", "*") #=> foo.2.dylib, foo.1.dylib, foo.dylib + # shared_library("*") #=> foo.dylib, bar.dylib + # </pre> + sig { params(name: String, version: T.nilable(T.any(String, Integer))).returns(String) } def shared_library(name, version = nil) return "*.dylib" if name == "*" && (version.blank? || version == "*") @@ -1675,6 +1683,8 @@ def any_installed_prefix end end + # Returns the {PkgVersion} for this formula if it is installed. + # If not, return `nil`. def any_installed_version any_installed_keg&.version end @@ -1981,7 +1991,8 @@ def undeclared_runtime_dependencies # has to be opened first. # <pre>system "./bootstrap.sh", "--arg1", "--prefix=#{prefix}"</pre> # - # For CMake we have some necessary defaults in {#std_cmake_args}: + # For CMake and other build systems we have some necessary defaults in e.g. + # {#std_cmake_args}: # <pre>system "cmake", ".", *std_cmake_args</pre> # # If the arguments given to `configure` (or `make` or `cmake`) are depending @@ -2435,24 +2446,19 @@ def sha256(val) # # <pre>bottle do # root_url "https://example.com" # Optional root to calculate bottle URLs. - # prefix "/opt/homebrew" # Optional HOMEBREW_PREFIX in which the bottles were built. # cellar "/opt/homebrew/Cellar" # Optional HOMEBREW_CELLAR in which the bottles were built. # rebuild 1 # Marks the old bottle as outdated without bumping the version/revision of the formula. # sha256 "ef65c759c5097a36323fa9c77756468649e8d1980a3a4e05695c05e39568967c" => :catalina # sha256 "28f4090610946a4eb207df102d841de23ced0d06ba31cb79e040d883906dcd4f" => :mojave # sha256 "91dd0caca9bd3f38c439d5a7b6f68440c4274945615fae035ff0a369264b8a2f" => :high_sierra # end</pre> # - # Only formulae where the upstream URL breaks or moves frequently, require compiling - # or have a reasonable amount of patches/resources should be bottled. - # Formulae which do not meet the above requirements should not be bottled. + # Homebrew maintainers aim to bottle all formulae that require compilation. # - # Formulae which should not be bottled and can be installed without any compile - # required should be tagged with: + # Formulae that can be installed without compilation should be tagged with: # <pre>bottle :unneeded</pre> # - # Otherwise formulae which do not meet the above requirements and should not - # be bottled should be tagged with: + # Formulae which should not be bottled should be tagged with: # <pre>bottle :disable, "reasons"</pre> def bottle(*args, &block) stable.bottle(*args, &block) @@ -2533,32 +2539,41 @@ def go_resource(name, &block) end # The dependencies for this formula. Use strings for the names of other - # formulae. Homebrew provides some :special dependencies for stuff that - # requires certain extra handling (often changing some ENV vars or - # deciding if to use the system provided version or not). - # <pre># `:build` means this dep is only needed during build. - # depends_on "cmake" => :build</pre> - # <pre># `:recommended` dependencies are built by default. - # # But a `--without-...` option is generated to opt-out. - # depends_on "readline" => :recommended</pre> - # <pre># `:optional` dependencies are NOT built by default unless the - # # auto-generated `--with-...` option is passed. - # depends_on "glib" => :optional</pre> - # <pre># If you need to specify that another formula has to be built with/out - # # certain options (note, no `--` needed before the option): - # depends_on "zeromq" => "with-pgm" + # formulae. Homebrew provides some `:special` {Requirement}s for stuff + # that needs extra handling (often changing some ENV vars or + # deciding whether to use the system provided version). + # + # `:build` means this dependency is only needed during build. + # <pre>depends_on "cmake" => :build</pre> + # + # `:test` means this dependency is only needed during testing. + # <pre>depends_on "node" => :test</pre> + # + # `:recommended` dependencies are built by default. + # But a `--without-...` option is generated to opt-out. + # <pre>depends_on "readline" => :recommended</pre> + # + # `:optional` dependencies are NOT built by default unless the + # auto-generated `--with-...` option is passed. + # <pre>depends_on "glib" => :optional</pre> + # + # If you need to specify that another formula has to be built with/out + # certain options (note, no `--` needed before the option): + # <pre>depends_on "zeromq" => "with-pgm" # depends_on "qt" => ["with-qtdbus", "developer"] # Multiple options.</pre> - # <pre># Optional and enforce that "boost" is built with `--with-c++11`. - # depends_on "boost" => [:optional, "with-c++11"]</pre> - # <pre># If a dependency is only needed in certain cases: - # depends_on "sqlite" if MacOS.version >= :catalina + # + # Optional and enforce that "boost" is built with `--with-c++11`. + # <pre>depends_on "boost" => [:optional, "with-c++11"]</pre> + # + # If a dependency is only needed in certain cases: + # <pre>depends_on "sqlite" if MacOS.version >= :catalina # depends_on xcode: :build # If the formula really needs full Xcode to compile. # depends_on macos: :mojave # Needs at least macOS Mojave (10.14) to run. - # <pre># It is possible to only depend on something if - # # `build.with?` or `build.without? "another_formula"`: - # depends_on "postgresql" if build.without? "sqlite"</pre> - # <pre># Require Python if `--with-python` is passed to `brew install example`: - # depends_on "python" => :optional</pre> + # </pre> + # + # It is possible to only depend on something if + # `build.with?` or `build.without? "another_formula"`: + # <pre>depends_on "postgresql" if build.without? "sqlite"</pre> def depends_on(dep) specs.each { |spec| spec.depends_on(dep) } end @@ -2659,6 +2674,13 @@ def conflicts_with(*names) names.each { |name| conflicts << FormulaConflict.new(name, opts[:because]) } end + # Skip cleaning paths in a formula. + # + # Sometimes the formula {Cleaner cleaner} breaks things. + # Preserve cleaned paths with: + # <pre>skip_clean "bin/foo", "lib/bar"</pre> + # Keep .la files with: + # <pre>skip_clean :la</pre> def skip_clean(*paths) paths.flatten! # Specifying :all is deprecated and will become an error @@ -2670,13 +2692,16 @@ def skip_clean_paths @skip_clean_paths ||= Set.new end - # Software that will not be symlinked into the `brew --prefix` will only - # live in its Cellar. Other formulae can depend on it and then brew will - # add the necessary includes and libs (etc.) during the brewing of that - # other formula. But generally, keg-only formulae are not in your PATH - # and not seen by compilers if you build your own software outside of - # Homebrew. This way, we don't shadow software provided by macOS. + # Software that will not be symlinked into the `brew --prefix` and will + # only live in its Cellar. Other formulae can depend on it and Homebrew + # will add the necessary includes, libraries, and other paths while + # building that other formula. + # + # Keg-only formulae are not in your PATH and are not seen by compilers + # if you build your own software outside of Homebrew. This way, we + # don't shadow software provided by macOS. # <pre>keg_only :provided_by_macos</pre> + # <pre>keg_only :versioned_formulae</pre> # <pre>keg_only "because I want it so"</pre> def keg_only(reason, explanation = "") @keg_only_reason = KegOnlyReason.new(reason, explanation) @@ -2712,6 +2737,15 @@ def fails_with(compiler, &block) specs.each { |spec| spec.fails_with(compiler, &block) } end + # Marks the {Formula} as needing a certain standard, so Homebrew + # will fall back to other compilers if the default compiler + # does not implement that standard. + # + # We generally prefer to {.depends_on} a desired compiler and to + # explicitly use that compiler in a formula's {#install} block, + # rather than implicitly finding a suitable compiler with `needs`. + # + # @see #fails_with def needs(*standards) specs.each { |spec| spec.needs(*standards) } end @@ -2749,9 +2783,9 @@ def test(&block) end # @!attribute [w] livecheck - # Livecheck can be used to check for newer versions of the software. + # {Livecheck} can be used to check for newer versions of the software. # This method evaluates the DSL specified in the livecheck block of the - # {Formula} (if it exists) and sets the instance variables of a Livecheck + # {Formula} (if it exists) and sets the instance variables of a {Livecheck} # object accordingly. This is used by `brew livecheck` to check for newer # versions of the software. # @@ -2790,6 +2824,8 @@ def pour_bottle?(&block) # will not be deprecated. # <pre>deprecate! date: "2020-08-27", because: :unmaintained</pre> # <pre>deprecate! date: "2020-08-27", because: "has been replaced by foo"</pre> + # @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae + # @see DeprecateDisable::DEPRECATE_DISABLE_REASONS def deprecate!(date: nil, because: nil) odeprecated "`deprecate!` without a reason", "`deprecate! because: \"reason\"`" if because.blank? odeprecated "`deprecate!` without a date", "`deprecate! date: \"#{Date.today}\"`" if date.blank? @@ -2805,25 +2841,30 @@ def deprecate!(date: nil, because: nil) # Whether this {Formula} is deprecated (i.e. warns on installation). # Defaults to false. # @return [Boolean] + # @see .deprecate! def deprecated? @deprecated == true end # The date that this {Formula} was or becomes deprecated. # Returns `nil` if no date is specified. # @return Date + # @see .deprecate! attr_reader :deprecation_date # The reason for deprecation of a {Formula}. # @return [nil] if no reason was provided or the formula is not deprecated. # @return [String, Symbol] + # @see .deprecate! attr_reader :deprecation_reason - # Disables a {Formula} (on a given date, if provided) so it cannot be + # Disables a {Formula} (on a given date, if provided) so it cannot be # installed. If the date has not yet passed the formula # will be deprecated instead of disabled. # <pre>disable! date: "2020-08-27", because: :does_not_build</pre> # <pre>disable! date: "2020-08-27", because: "has been replaced by foo"</pre> + # @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae + # @see DeprecateDisable::DEPRECATE_DISABLE_REASONS def disable!(date: nil, because: nil) odeprecated "`disable!` without a reason", "`disable! because: \"reason\"`" if because.blank? odeprecated "`disable!` without a date", "`disable! date: \"#{Date.today}\"`" if date.blank? @@ -2843,21 +2884,29 @@ def disable!(date: nil, because: nil) # Whether this {Formula} is disabled (i.e. cannot be installed). # Defaults to false. # @return [Boolean] + # @see .disable! def disabled? @disabled == true end # The date that this {Formula} was or becomes disabled. # Returns `nil` if no date is specified. # @return Date + # @see .disable! attr_reader :disable_date # The reason this {Formula} is disabled. # Returns `nil` if no reason was provided or the formula is not disabled. # @return [String, Symbol] + # @see .disable! attr_reader :disable_reason - # @private + # Permit overwriting certain files while linking. + # + # Sometimes we accidentally install files outside prefix. Once we fix that, + # users will get a link conflict error. Overwrite those files with: + # <pre>link_overwrite "bin/foo", "lib/bar"</pre> + # <pre>link_overwrite "share/man/man1/baz-*"</pre> def link_overwrite(*paths) paths.flatten! link_overwrite_paths.merge(paths) @@ -2868,6 +2917,7 @@ def link_overwrite_paths @link_overwrite_paths ||= Set.new end + # Permit links to certain libraries that don't exist. Available on Linux only. def ignore_missing_libraries(*) raise FormulaSpecificationError, "#{__method__} is available on Linux only" end
true
Other
Homebrew
brew
ce45868973620a1fed4505e0fc9c2f9a928bdff0.json
Improve documentation and add type signatures.
Library/Homebrew/utils/inreplace.rb
@@ -23,14 +23,22 @@ def initialize(errors) module_function # Sometimes we have to change a bit before we install. Mostly we - # prefer a patch but if you need the `prefix` of this formula in the - # patch you have to resort to `inreplace`, because in the patch - # you don't have access to any var defined by the formula. Only - # `HOMEBREW_PREFIX` is available in the embedded patch. + # prefer a patch, but if you need the {Formula#prefix prefix} of + # this formula in the patch you have to resort to `inreplace`, + # because in the patch you don't have access to any variables + # defined by the formula, as only `HOMEBREW_PREFIX` is available + # in the {DATAPatch embedded patch}. # # `inreplace` supports regular expressions: # <pre>inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool"</pre> # + # `inreplace` supports blocks: + # <pre>inreplace "Makefile" do |s| + # s.gsub! "/usr/local", HOMEBREW_PREFIX.to_s + # end + # </pre> + # + # @see StringInreplaceExtension # @api public sig do params( @@ -65,6 +73,7 @@ def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:d raise Error, errors unless errors.empty? end + # @api private def inreplace_pairs(path, replacement_pairs, read_only_run: false, silent: false) str = File.open(path, "rb", &:read) || "" contents = StringInreplaceExtension.new(str)
true
Other
Homebrew
brew
ce45868973620a1fed4505e0fc9c2f9a928bdff0.json
Improve documentation and add type signatures.
docs/Bottles.md
@@ -33,7 +33,6 @@ A full example: ```ruby bottle do root_url "https://example.com" - prefix "/opt/homebrew" cellar "/opt/homebrew/Cellar" rebuild 4 sha256 "4921af80137af9cc3d38fd17c9120da882448a090b0a8a3a19af3199b415bfca" => :sierra @@ -50,10 +49,6 @@ By default this is omitted and the Homebrew default bottle URL root is used. Thi Optionally contains the value of `HOMEBREW_CELLAR` in which the bottles were built. Most compiled software contains references to its compiled location so cannot be simply relocated anywhere on disk. If this value is `:any` or `:any_skip_relocation` this means that the bottle can be safely installed in any Cellar as it did not contain any references to its installation Cellar. This can be omitted if a bottle is compiled (as all default Homebrew ones are) for the default `HOMEBREW_CELLAR` of `/usr/local/Cellar`. -### Prefix (`prefix`) -Optionally contains the value of `HOMEBREW_PREFIX` in which the bottles were built. -See description of `cellar`. When `cellar` is `:any` or `:any_skip_relocation` the prefix should be omitted. - ### Rebuild version (`rebuild`) Optionally contains the rebuild version of the bottle. Sometimes bottles may need be updated without bumping the version of the formula, e.g. a new patch was applied. In that case the rebuild will have a value of 1 or more.
true
Other
Homebrew
brew
bed16128cc73b9a18f1a5b5b26d4f30e095fdb29.json
completions: fix usage text
Library/Homebrew/cmd/completions.rb
@@ -15,7 +15,7 @@ def completions_args usage_banner <<~EOS `completions` [<subcommand>] - Control whether Homebrew automatically links shell files. + Control whether Homebrew automatically links shell completion files. Read more at <https://docs.brew.sh/Shell-Completion>. `brew completions` [`state`]:
true
Other
Homebrew
brew
bed16128cc73b9a18f1a5b5b26d4f30e095fdb29.json
completions: fix usage text
docs/Manpage.md
@@ -96,7 +96,7 @@ Show lists of built-in and external commands. ### `completions` [*`subcommand`*] -Control whether Homebrew automatically links shell files. +Control whether Homebrew automatically links shell completion files. Read more at <https://docs.brew.sh/Shell-Completion>. `brew completions` [`state`]
true
Other
Homebrew
brew
bed16128cc73b9a18f1a5b5b26d4f30e095fdb29.json
completions: fix usage text
manpages/brew.1
@@ -94,7 +94,7 @@ List only the names of commands without category headers\. Include aliases of internal commands\. . .SS "\fBcompletions\fR [\fIsubcommand\fR]" -Control whether Homebrew automatically links shell files\. Read more at \fIhttps://docs\.brew\.sh/Shell\-Completion\fR\. +Control whether Homebrew automatically links shell completion files\. Read more at \fIhttps://docs\.brew\.sh/Shell\-Completion\fR\. . .P \fBbrew completions\fR [\fBstate\fR]
true
Other
Homebrew
brew
2ebfb4221cac250ba31c07fadd7aadd1c9c6594b.json
utils/ast: add `FormulaAST` class
Library/Homebrew/dev-cmd/bottle.rb
@@ -493,22 +493,22 @@ def merge(args:) require "utils/ast" path = Pathname.new((HOMEBREW_REPOSITORY/bottle_hash["formula"]["path"]).to_s) - checksums = old_checksums(path, bottle_hash, args: args) + formula = Formulary.factory(path) + formula_ast = Utils::AST::FormulaAST.new(path.read) + checksums = old_checksums(formula, formula_ast, bottle_hash, args: args) update_or_add = checksums.nil? ? "add" : "update" checksums&.each(&bottle.method(:sha256)) output = bottle_output(bottle) puts output - Utils::Inreplace.inreplace(path) do |s| - formula_contents = s.inreplace_string - case update_or_add - when "update" - Utils::AST.replace_bottle_stanza!(formula_contents, output) - when "add" - Utils::AST.add_bottle_stanza!(formula_contents, output) - end + case update_or_add + when "update" + formula_ast.replace_bottle_block(output) + when "add" + formula_ast.add_bottle_block(output) end + path.atomic_write(formula_ast.process) unless args.no_commit? Utils::Git.set_name_email! @@ -566,16 +566,16 @@ def merge_bottle_spec(old_keys, old_bottle_spec, new_bottle_hash) [mismatches, checksums] end - def old_checksums(formula_path, bottle_hash, args:) - bottle_node = Utils::AST.bottle_block(formula_path.read) + def old_checksums(formula, formula_ast, bottle_hash, args:) + bottle_node = formula_ast.bottle_block if bottle_node.nil? odie "--keep-old was passed but there was no existing bottle block!" if args.keep_old? return end return [] unless args.keep_old? - old_keys = Utils::AST.body_children(bottle_node.body).map(&:method_name) - old_bottle_spec = Formulary.factory(formula_path).bottle_specification + old_keys = Utils::AST::FormulaAST.body_children(bottle_node.body).map(&:method_name) + old_bottle_spec = formula.bottle_specification mismatches, checksums = merge_bottle_spec(old_keys, old_bottle_spec, bottle_hash["bottle"]) if mismatches.present? odie <<~EOS
true
Other
Homebrew
brew
2ebfb4221cac250ba31c07fadd7aadd1c9c6594b.json
utils/ast: add `FormulaAST` class
Library/Homebrew/dev-cmd/bump-revision.rb
@@ -52,14 +52,13 @@ def bump_revision Homebrew.install_bundler_gems! require "utils/ast" - Utils::Inreplace.inreplace(formula.path) do |s| - s = s.inreplace_string - if current_revision.zero? - Utils::AST.add_formula_stanza!(s, :revision, new_revision) - else - Utils::AST.replace_formula_stanza!(s, :revision, new_revision) - end + formula_ast = Utils::AST::FormulaAST.new(formula.path.read) + if current_revision.zero? + formula_ast.add_stanza(:revision, new_revision) + else + formula_ast.replace_stanza(:revision, new_revision) end + formula.path.atomic_write(formula_ast.process) end message = "#{formula.name}: revision bump #{args.message}"
true
Other
Homebrew
brew
2ebfb4221cac250ba31c07fadd7aadd1c9c6594b.json
utils/ast: add `FormulaAST` class
Library/Homebrew/test/utils/ast_spec.rb
@@ -3,9 +3,9 @@ require "utils/ast" -describe Utils::AST do - let(:initial_formula) do - <<~RUBY +describe Utils::AST::FormulaAST do + subject(:formula_ast) do + described_class.new <<~RUBY class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" license all_of: [ @@ -17,11 +17,10 @@ class Foo < Formula RUBY end - describe ".replace_formula_stanza!" do + describe "#replace_stanza" do it "replaces the specified stanza in a formula" do - contents = initial_formula.dup - described_class.replace_formula_stanza!(contents, :license, :public_domain) - expect(contents).to eq <<~RUBY + formula_ast.replace_stanza(:license, :public_domain) + expect(formula_ast.process).to eq <<~RUBY class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" license :public_domain @@ -30,11 +29,10 @@ class Foo < Formula end end - describe ".add_formula_stanza!" do + describe "#add_stanza" do it "adds the specified stanza to a formula" do - contents = initial_formula.dup - described_class.add_formula_stanza!(contents, :revision, 1) - expect(contents).to eq <<~RUBY + formula_ast.add_stanza(:revision, 1) + expect(formula_ast.process).to eq <<~RUBY class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" license all_of: [ @@ -92,7 +90,7 @@ class Foo < Formula end end - describe ".add_bottle_stanza!" do + describe "#add_bottle_block" do let(:bottle_output) do <<~RUBY.chomp.indent(2) bottle do @@ -102,8 +100,8 @@ class Foo < Formula end context "when `license` is a string" do - let(:formula_contents) do - <<~RUBY.chomp + subject(:formula_ast) do + described_class.new <<~RUBY.chomp class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" license "MIT" @@ -125,14 +123,14 @@ class Foo < Formula end it "adds `bottle` after `license`" do - described_class.add_bottle_stanza!(formula_contents, bottle_output) - expect(formula_contents).to eq(new_contents) + formula_ast.add_bottle_block(bottle_output) + expect(formula_ast.process).to eq(new_contents) end end context "when `license` is a symbol" do - let(:formula_contents) do - <<~RUBY.chomp + subject(:formula_ast) do + described_class.new <<~RUBY.chomp class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" license :cannot_represent @@ -154,14 +152,14 @@ class Foo < Formula end it "adds `bottle` after `license`" do - described_class.add_bottle_stanza!(formula_contents, bottle_output) - expect(formula_contents).to eq(new_contents) + formula_ast.add_bottle_block(bottle_output) + expect(formula_ast.process).to eq(new_contents) end end context "when `license` is multiline" do - let(:formula_contents) do - <<~RUBY.chomp + subject(:formula_ast) do + described_class.new <<~RUBY.chomp class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" license all_of: [ @@ -191,14 +189,14 @@ class Foo < Formula end it "adds `bottle` after `license`" do - described_class.add_bottle_stanza!(formula_contents, bottle_output) - expect(formula_contents).to eq(new_contents) + formula_ast.add_bottle_block(bottle_output) + expect(formula_ast.process).to eq(new_contents) end end context "when `head` is a string" do - let(:formula_contents) do - <<~RUBY.chomp + subject(:formula_ast) do + described_class.new <<~RUBY.chomp class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" head "https://brew.sh/foo.git" @@ -220,14 +218,14 @@ class Foo < Formula end it "adds `bottle` after `head`" do - described_class.add_bottle_stanza!(formula_contents, bottle_output) - expect(formula_contents).to eq(new_contents) + formula_ast.add_bottle_block(bottle_output) + expect(formula_ast.process).to eq(new_contents) end end context "when `head` is a block" do - let(:formula_contents) do - <<~RUBY.chomp + subject(:formula_ast) do + described_class.new <<~RUBY.chomp class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" @@ -255,14 +253,14 @@ class Foo < Formula end it "adds `bottle` before `head`" do - described_class.add_bottle_stanza!(formula_contents, bottle_output) - expect(formula_contents).to eq(new_contents) + formula_ast.add_bottle_block(bottle_output) + expect(formula_ast.process).to eq(new_contents) end end context "when there is a comment on the same line" do - let(:formula_contents) do - <<~RUBY.chomp + subject(:formula_ast) do + described_class.new <<~RUBY.chomp class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" # comment end @@ -282,14 +280,14 @@ class Foo < Formula end it "adds `bottle` after the comment" do - described_class.add_bottle_stanza!(formula_contents, bottle_output) - expect(formula_contents).to eq(new_contents) + formula_ast.add_bottle_block(bottle_output) + expect(formula_ast.process).to eq(new_contents) end end context "when the next line is a comment" do - let(:formula_contents) do - <<~RUBY.chomp + subject(:formula_ast) do + described_class.new <<~RUBY.chomp class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" # comment @@ -311,14 +309,14 @@ class Foo < Formula end it "adds `bottle` after the comment" do - described_class.add_bottle_stanza!(formula_contents, bottle_output) - expect(formula_contents).to eq(new_contents) + formula_ast.add_bottle_block(bottle_output) + expect(formula_ast.process).to eq(new_contents) end end context "when the next line is blank and the one after it is a comment" do - let(:formula_contents) do - <<~RUBY.chomp + subject(:formula_ast) do + described_class.new <<~RUBY.chomp class Foo < Formula url "https://brew.sh/foo-1.0.tar.gz" @@ -342,8 +340,8 @@ class Foo < Formula end it "adds `bottle` before the comment" do - described_class.add_bottle_stanza!(formula_contents, bottle_output) - expect(formula_contents).to eq(new_contents) + formula_ast.add_bottle_block(bottle_output) + expect(formula_ast.process).to eq(new_contents) end end end
true
Other
Homebrew
brew
2ebfb4221cac250ba31c07fadd7aadd1c9c6594b.json
utils/ast: add `FormulaAST` class
Library/Homebrew/utils/ast.rb
@@ -13,12 +13,28 @@ module AST SendNode = RuboCop::AST::SendNode BlockNode = RuboCop::AST::BlockNode ProcessedSource = RuboCop::AST::ProcessedSource + TreeRewriter = Parser::Source::TreeRewriter - class << self + # Helper class for editing formulae. + # + # @api private + class FormulaAST extend T::Sig + extend Forwardable + + delegate process: :tree_rewriter + + sig { params(formula_contents: String).void } + def initialize(formula_contents) + @formula_contents = formula_contents + processed_source, children = process_formula + @processed_source = T.let(processed_source, ProcessedSource) + @children = T.let(children, T::Array[Node]) + @tree_rewriter = T.let(TreeRewriter.new(processed_source.buffer), TreeRewriter) + end sig { params(body_node: Node).returns(T::Array[Node]) } - def body_children(body_node) + def self.body_children(body_node) if body_node.nil? [] elsif body_node.begin_type? @@ -28,56 +44,36 @@ def body_children(body_node) end end - sig { params(formula_contents: String).returns(T.nilable(Node)) } - def bottle_block(formula_contents) - formula_stanza(formula_contents, :bottle, type: :block_call) + sig { returns(T.nilable(Node)) } + def bottle_block + stanza(:bottle, type: :block_call) end - sig { params(formula_contents: String, name: Symbol, type: T.nilable(Symbol)).returns(T.nilable(Node)) } - def formula_stanza(formula_contents, name, type: nil) - _, children = process_formula(formula_contents) + sig { params(name: Symbol, type: T.nilable(Symbol)).returns(T.nilable(Node)) } + def stanza(name, type: nil) children.find { |child| call_node_match?(child, name: name, type: type) } end - sig { params(formula_contents: String, bottle_output: String).void } - def replace_bottle_stanza!(formula_contents, bottle_output) - replace_formula_stanza!(formula_contents, :bottle, bottle_output.chomp, type: :block_call) + sig { params(bottle_output: String).void } + def replace_bottle_block(bottle_output) + replace_stanza(:bottle, bottle_output.chomp, type: :block_call) end - sig { params(formula_contents: String, bottle_output: String).void } - def add_bottle_stanza!(formula_contents, bottle_output) - add_formula_stanza!(formula_contents, :bottle, "\n#{bottle_output.chomp}", type: :block_call) + sig { params(bottle_output: String).void } + def add_bottle_block(bottle_output) + add_stanza(:bottle, "\n#{bottle_output.chomp}", type: :block_call) end - sig do - params( - formula_contents: String, - name: Symbol, - replacement: T.any(Numeric, String, Symbol), - type: T.nilable(Symbol), - ).void - end - def replace_formula_stanza!(formula_contents, name, replacement, type: nil) - processed_source, children = process_formula(formula_contents) + sig { params(name: Symbol, replacement: T.any(Numeric, String, Symbol), type: T.nilable(Symbol)).void } + def replace_stanza(name, replacement, type: nil) stanza_node = children.find { |child| call_node_match?(child, name: name, type: type) } raise "Could not find #{name} stanza!" if stanza_node.nil? - tree_rewriter = Parser::Source::TreeRewriter.new(processed_source.buffer) - tree_rewriter.replace(stanza_node.source_range, stanza_text(name, replacement, indent: 2).lstrip) - formula_contents.replace(tree_rewriter.process) - end - - sig do - params( - formula_contents: String, - name: Symbol, - value: T.any(Numeric, String, Symbol), - type: T.nilable(Symbol), - ).void + tree_rewriter.replace(stanza_node.source_range, self.class.stanza_text(name, replacement, indent: 2).lstrip) end - def add_formula_stanza!(formula_contents, name, value, type: nil) - processed_source, children = process_formula(formula_contents) + sig { params(name: Symbol, value: T.any(Numeric, String, Symbol), type: T.nilable(Symbol)).void } + def add_stanza(name, value, type: nil) preceding_component = if children.length > 1 children.reduce do |previous_child, current_child| if formula_component_before_target?(current_child, @@ -108,13 +104,11 @@ def add_formula_stanza!(formula_contents, name, value, type: nil) end end - tree_rewriter = Parser::Source::TreeRewriter.new(processed_source.buffer) - tree_rewriter.insert_after(preceding_expr, "\n#{stanza_text(name, value, indent: 2)}") - formula_contents.replace(tree_rewriter.process) + tree_rewriter.insert_after(preceding_expr, "\n#{self.class.stanza_text(name, value, indent: 2)}") end sig { params(name: Symbol, value: T.any(Numeric, String, Symbol), indent: T.nilable(Integer)).returns(String) } - def stanza_text(name, value, indent: nil) + def self.stanza_text(name, value, indent: nil) text = if value.is_a?(String) _, node = process_source(value) value if (node.is_a?(SendNode) || node.is_a?(BlockNode)) && node.method_name == name @@ -124,19 +118,31 @@ def stanza_text(name, value, indent: nil) text end - private - sig { params(source: String).returns([ProcessedSource, Node]) } - def process_source(source) + def self.process_source(source) ruby_version = Version.new(HOMEBREW_REQUIRED_RUBY_VERSION).major_minor.to_f processed_source = ProcessedSource.new(source, ruby_version) root_node = processed_source.ast [processed_source, root_node] end - sig { params(formula_contents: String).returns([ProcessedSource, T::Array[Node]]) } - def process_formula(formula_contents) - processed_source, root_node = process_source(formula_contents) + private + + sig { returns(String) } + attr_reader :formula_contents + + sig { returns(ProcessedSource) } + attr_reader :processed_source + + sig { returns(T::Array[Node]) } + attr_reader :children + + sig { returns(TreeRewriter) } + attr_reader :tree_rewriter + + sig { returns([ProcessedSource, T::Array[Node]]) } + def process_formula + processed_source, root_node = self.class.process_source(formula_contents) class_node = if root_node.class_type? root_node @@ -146,7 +152,7 @@ def process_formula(formula_contents) raise "Could not find formula class!" if class_node.nil? - children = body_children(class_node.body) + children = self.class.body_children(class_node.body) raise "Formula class is empty!" if children.empty? [processed_source, children]
true
Other
Homebrew
brew
2ebfb4221cac250ba31c07fadd7aadd1c9c6594b.json
utils/ast: add `FormulaAST` class
Library/Homebrew/utils/ast.rbi
@@ -0,0 +1,7 @@ +# typed: strict + +module Utils + module AST + include ::Kernel + end +end
true