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
deffac58cd2c4a596ea0573c3f91cb239fd2c1ff.json
sorbet: update RBI files using Tapioca. Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/tapioca.yml).
Library/Homebrew/sorbet/rbi/gems/codecov@0.2.7.rbi
@@ -0,0 +1,8 @@ +# DO NOT EDIT MANUALLY +# This is an autogenerated file for types exported from the `codecov` gem. +# Please instead update this file by running `tapioca sync --exclude json`. + +# typed: true + +# THIS IS AN EMPTY RBI FILE. +# see https://github.com/Shopify/tapioca/blob/master/README.md#manual-gem-requires
true
Other
Homebrew
brew
deffac58cd2c4a596ea0573c3f91cb239fd2c1ff.json
sorbet: update RBI files using Tapioca. Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/tapioca.yml).
Library/Homebrew/sorbet/rbi/gems/tapioca@0.4.3.rbi
@@ -0,0 +1,537 @@ +# DO NOT EDIT MANUALLY +# This is an autogenerated file for types exported from the `tapioca` gem. +# Please instead update this file by running `tapioca sync --exclude json`. + +# typed: true + +module Tapioca + class << self + def silence_warnings(&blk); end + end +end + +class Tapioca::Cli < ::Thor + include(::Thor::Actions) + extend(::Thor::Actions::ClassMethods) + + def dsl(*constants); end + def generate(*gems); end + def generator; end + def init; end + def require; end + def sync; end + def todo; end + + class << self + def exit_on_failure?; end + end +end + +module Tapioca::Compilers +end + +module Tapioca::Compilers::Dsl +end + +class Tapioca::Compilers::Dsl::Base + abstract! + + sig { void } + def initialize; end + + sig { abstract.type_parameters(:T).params(root: Parlour::RbiGenerator::Namespace, constant: T.type_parameter(:T)).void } + def decorate(root, constant); end + sig { abstract.returns(T::Enumerable[Module]) } + def gather_constants; end + sig { params(constant: Module).returns(T::Boolean) } + def handles?(constant); end + sig { returns(T::Set[Module]) } + def processable_constants; end + + private + + sig { params(method_def: T.any(Method, UnboundMethod)).returns(T::Array[Parlour::RbiGenerator::Parameter]) } + def compile_method_parameters_to_parlour(method_def); end + sig { params(method_def: T.any(Method, UnboundMethod)).returns(String) } + def compile_method_return_type_to_parlour(method_def); end + sig { params(namespace: Parlour::RbiGenerator::Namespace, name: String, options: T::Hash[T.untyped, T.untyped]).void } + def create_method(namespace, name, options = T.unsafe(nil)); end + sig { params(namespace: Parlour::RbiGenerator::Namespace, method_def: T.any(Method, UnboundMethod), class_method: T::Boolean).void } + def create_method_from_def(namespace, method_def, class_method: T.unsafe(nil)); end + sig { params(method_def: T.any(Method, UnboundMethod), signature: T.untyped).returns(T::Array[String]) } + def parameters_types_from_signature(method_def, signature); end + sig { params(name: String).returns(T::Boolean) } + def valid_method_name?(name); end +end + +Tapioca::Compilers::Dsl::Base::SPECIAL_METHOD_NAMES = T.let(T.unsafe(nil), Array) + +class Tapioca::Compilers::DslCompiler + sig { params(requested_constants: T::Array[Module], requested_generators: T::Array[String], error_handler: T.nilable(T.proc.params(error: String).void)).void } + def initialize(requested_constants:, requested_generators: T.unsafe(nil), error_handler: T.unsafe(nil)); end + + sig { returns(T.proc.params(error: String).void) } + def error_handler; end + sig { returns(T::Enumerable[Tapioca::Compilers::Dsl::Base]) } + def generators; end + sig { returns(T::Array[Module]) } + def requested_constants; end + sig { params(blk: T.proc.params(constant: Module, rbi: String).void).void } + def run(&blk); end + + private + + sig { params(requested_constants: T::Array[Module]).returns(T::Set[Module]) } + def gather_constants(requested_constants); end + sig { params(requested_generators: T::Array[String]).returns(T::Enumerable[Tapioca::Compilers::Dsl::Base]) } + def gather_generators(requested_generators); end + sig { params(requested_generators: T::Array[String]).returns(Proc) } + def generator_filter(requested_generators); end + sig { params(constant: Module).returns(T.nilable(String)) } + def rbi_for_constant(constant); end + sig { params(error: String).returns(T.noreturn) } + def report_error(error); end + sig { params(parlour: Parlour::RbiGenerator).void } + def resolve_conflicts(parlour); end +end + +class Tapioca::Compilers::RequiresCompiler + sig { params(sorbet_path: String).void } + def initialize(sorbet_path); end + + sig { returns(String) } + def compile; end + + private + + sig { params(config: Tapioca::SorbetConfig).returns(T::Array[String]) } + def collect_files(config); end + sig { params(file_path: String).returns(T::Enumerable[String]) } + def collect_requires(file_path); end + sig { params(config: Tapioca::SorbetConfig, file: String).returns(T::Boolean) } + def file_ignored_by_sorbet?(config, file); end + sig { params(files: T::Enumerable[String], name: String).returns(T::Boolean) } + def name_in_project?(files, name); end +end + +module Tapioca::Compilers::Sorbet + class << self + sig { params(args: String).returns(String) } + def run(*args); end + sig { returns(String) } + def sorbet_path; end + end +end + +Tapioca::Compilers::Sorbet::SORBET = T.let(T.unsafe(nil), Pathname) + +module Tapioca::Compilers::SymbolTable +end + +class Tapioca::Compilers::SymbolTable::SymbolGenerator + sig { params(gem: Tapioca::Gemfile::Gem, indent: Integer).void } + def initialize(gem, indent = T.unsafe(nil)); end + + def gem; end + sig { returns(String) } + def generate; end + def indent; end + + private + + sig { params(name: String).void } + def add_to_alias_namespace(name); end + sig { params(name: String).returns(T::Boolean) } + def alias_namespaced?(name); end + sig { params(constant: Module, other: BasicObject).returns(T::Boolean) } + def are_equal?(constant, other); end + sig { params(constant: BasicObject).returns(Class) } + def class_of(constant); end + sig { params(name: T.nilable(String), constant: BasicObject).returns(T.nilable(String)) } + def compile(name, constant); end + sig { params(name: String, constant: Module).returns(T.nilable(String)) } + def compile_alias(name, constant); end + sig { params(name: String, constant: Module).returns(T.nilable(String)) } + def compile_body(name, constant); end + sig { params(name: String, constant: BasicObject).returns(T.nilable(String)) } + def compile_constant(name, constant); end + sig { params(module_name: String, mod: Module, for_visibility: T::Array[Symbol]).returns(String) } + def compile_directly_owned_methods(module_name, mod, for_visibility = T.unsafe(nil)); end + sig { params(symbol_name: String, constant: Module, method: T.nilable(UnboundMethod)).returns(T.nilable(String)) } + def compile_method(symbol_name, constant, method); end + sig { params(name: String, constant: Module).returns(T.nilable(String)) } + def compile_methods(name, constant); end + sig { params(constant: Module).returns(String) } + def compile_mixes_in_class_methods(constant); end + sig { params(constant: Module).returns(String) } + def compile_mixins(constant); end + sig { params(name: String, constant: Module).returns(T.nilable(String)) } + def compile_module(name, constant); end + sig { params(constant: Module).returns(String) } + def compile_module_helpers(constant); end + sig { params(name: String, value: BasicObject).returns(T.nilable(String)) } + def compile_object(name, value); end + sig { params(constant: Module).returns(String) } + def compile_props(constant); end + sig { params(signature: T.untyped).returns(String) } + def compile_signature(signature); end + sig { params(name: String, constant: Module).returns(T.nilable(String)) } + def compile_subconstants(name, constant); end + sig { params(constant: Class).returns(String) } + def compile_superclass(constant); end + sig { params(constant: Module).returns(T::Array[Symbol]) } + def constants_of(constant); end + sig { params(constant: Module, strict: T::Boolean).returns(T::Boolean) } + def defined_in_gem?(constant, strict: T.unsafe(nil)); end + sig { params(symbols: T::Set[String]).returns(T::Set[String]) } + def engine_symbols(symbols); end + sig { params(symbol: String).returns(T.nilable(String)) } + def generate_from_symbol(symbol); end + sig { params(constant: Module).returns(T::Array[String]) } + def get_file_candidates(constant); end + sig { params(str: String).returns(String) } + def indented(str); end + def initialize_method_for(constant); end + sig { params(name: String).void } + def mark_seen(name); end + sig { params(method: UnboundMethod).returns(T::Boolean) } + def method_in_gem?(method); end + sig { params(mod: Module).returns(T::Hash[Symbol, T::Array[Symbol]]) } + def method_names_by_visibility(mod); end + sig { params(constant: Module).returns(T.nilable(String)) } + def name_of(constant); end + sig { params(constant: Module).returns(T.nilable(String)) } + def name_of_proxy_target(constant); 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(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) } + def singleton_class_of(constant); end + sig { params(constant: Module, method_name: String).returns(T::Boolean) } + def struct_method?(constant, method_name); end + sig { params(constant: Class).returns(T.nilable(Class)) } + def superclass_of(constant); end + sig { params(symbol_name: String).returns(T::Boolean) } + def symbol_ignored?(symbol_name); end + sig { returns(T::Set[String]) } + def symbols; end + sig { params(name: String).returns(T::Boolean) } + def valid_method_name?(name); end + sig { type_parameters(:U).params(step: Integer, _blk: T.proc.params().returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) } + def with_indentation(step = T.unsafe(nil), &_blk); end +end + +Tapioca::Compilers::SymbolTable::SymbolGenerator::IGNORED_SYMBOLS = T.let(T.unsafe(nil), Array) + +Tapioca::Compilers::SymbolTable::SymbolGenerator::SPECIAL_METHOD_NAMES = T.let(T.unsafe(nil), Array) + +Tapioca::Compilers::SymbolTable::SymbolGenerator::TYPE_PARAMETER_MATCHER = T.let(T.unsafe(nil), Regexp) + +module Tapioca::Compilers::SymbolTable::SymbolLoader + class << self + def ignore_symbol?(symbol); end + sig { params(paths: T::Array[Pathname]).returns(T::Set[String]) } + def list_from_paths(paths); end + + private + + def ignored_symbols; end + sig { params(paths: T::Array[String]).returns(T::Set[String]) } + def load_symbols(paths); end + def symbol_table_json_from(input, table_type: T.unsafe(nil)); end + end +end + +class Tapioca::Compilers::SymbolTable::SymbolLoader::SymbolTableParser + class << self + def parse(object, parents = T.unsafe(nil)); end + end +end + +class Tapioca::Compilers::SymbolTableCompiler + sig { params(gem: Tapioca::Gemfile::Gem, indent: Integer).returns(String) } + def compile(gem, indent = T.unsafe(nil)); end +end + +class Tapioca::Compilers::TodosCompiler + sig { returns(String) } + def compile; end + + private + + sig { returns(String) } + def list_todos; end +end + +class Tapioca::Config < ::T::Struct + const :outdir, String + const :prerequire, T.nilable(String) + const :postrequire, String + const :generate_command, String + const :exclude, T::Array[String] + const :typed_overrides, T::Hash[String, String] + const :todos_path, String + const :generators, T::Array[String] + + sig { returns(Pathname) } + def outpath; end + + class << self + def inherited(s); end + end +end + +Tapioca::Config::DEFAULT_DSLDIR = T.let(T.unsafe(nil), String) + +Tapioca::Config::DEFAULT_GEMDIR = T.let(T.unsafe(nil), String) + +Tapioca::Config::DEFAULT_OVERRIDES = T.let(T.unsafe(nil), Hash) + +Tapioca::Config::DEFAULT_POSTREQUIRE = T.let(T.unsafe(nil), String) + +Tapioca::Config::DEFAULT_RBIDIR = T.let(T.unsafe(nil), String) + +Tapioca::Config::DEFAULT_TODOSPATH = T.let(T.unsafe(nil), String) + +Tapioca::Config::SORBET_CONFIG = T.let(T.unsafe(nil), String) + +Tapioca::Config::SORBET_PATH = T.let(T.unsafe(nil), String) + +Tapioca::Config::TAPIOCA_CONFIG = T.let(T.unsafe(nil), String) + +Tapioca::Config::TAPIOCA_PATH = T.let(T.unsafe(nil), String) + +class Tapioca::ConfigBuilder + class << self + sig { params(command: Symbol, options: T::Hash[String, T.untyped]).returns(Tapioca::Config) } + def from_options(command, options); end + + private + + sig { returns(T::Hash[String, T.untyped]) } + def config_options; end + sig { returns(String) } + def default_command; end + sig { params(command: Symbol).returns(T::Hash[String, T.untyped]) } + def default_options(command); end + sig { params(options: T::Hash[String, T.untyped]).returns(T::Hash[String, T.untyped]) } + def merge_options(*options); end + end +end + +Tapioca::ConfigBuilder::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash) + +module Tapioca::ConstantLocator + + private + + def files_for(klass); end + + class << self + def files_for(klass); end + end +end + +class Tapioca::Error < ::StandardError +end + +class Tapioca::Gemfile + sig { void } + def initialize; end + + sig { returns(T::Array[Tapioca::Gemfile::Gem]) } + def dependencies; end + sig { params(gem_name: String).returns(T.nilable(Tapioca::Gemfile::Gem)) } + def gem(gem_name); end + sig { void } + def require; end + + private + + sig { returns(Bundler::Definition) } + def definition; end + sig { returns(String) } + def dir; end + sig { returns(File) } + def gemfile; end + sig { returns(T::Array[Symbol]) } + def groups; end + def lockfile; end + sig { returns(Bundler::Runtime) } + def runtime; end +end + +class Tapioca::Gemfile::Gem + sig { params(spec: T.any(Gem::Specification, T.all(Bundler::RemoteSpecification, Bundler::StubSpecification))).void } + def initialize(spec); end + + sig { params(path: String).returns(T::Boolean) } + def contains_path?(path); end + sig { returns(T::Array[Pathname]) } + def files; end + sig { returns(String) } + def full_gem_path; end + sig { params(gemfile_dir: String).returns(T::Boolean) } + def ignore?(gemfile_dir); end + sig { returns(String) } + def name; end + sig { returns(String) } + def rbi_file_name; end + def version; end + + private + + sig { returns(T::Boolean) } + def gem_ignored?; end + sig { params(gemfile_dir: String).returns(T::Boolean) } + def gem_in_app_dir?(gemfile_dir); end + sig { returns(T::Boolean) } + def gem_in_bundle_path?; end + sig { params(path: String).returns(T::Boolean) } + def has_parent_gemspec?(path); end + sig { params(path: T.any(Pathname, String)).returns(String) } + def to_realpath(path); end + sig { returns(String) } + def version_string; end +end + +Tapioca::Gemfile::Gem::IGNORED_GEMS = T.let(T.unsafe(nil), Array) + +class Tapioca::Generator < ::Thor::Shell::Color + sig { params(config: Tapioca::Config).void } + def initialize(config); end + + sig { params(requested_constants: T::Array[String]).void } + def build_dsl(requested_constants); end + sig { params(gem_names: T::Array[String]).void } + def build_gem_rbis(gem_names); end + sig { void } + def build_requires; end + sig { void } + def build_todos; end + sig { returns(Tapioca::Config) } + def config; end + sig { void } + def sync_rbis_with_gemfile; end + + private + + sig { params(filename: Pathname).void } + def add(filename); end + sig { returns(T::Array[String]) } + def added_rbis; end + sig { returns(Tapioca::Gemfile) } + def bundle; end + sig { params(constant: Module, contents: String).void } + def compile_dsl_rbi(constant, contents); end + sig { params(gem: Tapioca::Gemfile::Gem).void } + def compile_gem_rbi(gem); end + sig { returns(Tapioca::Compilers::SymbolTableCompiler) } + def compiler; end + sig { params(constant_names: T::Array[String]).returns(T::Array[Module]) } + def constantize(constant_names); end + sig { params(gem_name: String).returns(Pathname) } + def existing_rbi(gem_name); end + sig { returns(T::Hash[String, String]) } + def existing_rbis; end + sig { params(gem_name: String).returns(Pathname) } + def expected_rbi(gem_name); end + sig { returns(T::Hash[String, String]) } + def expected_rbis; end + sig { params(file: String, error: LoadError).void } + def explain_failed_require(file, error); end + sig { params(gem_name: String).returns(T::Boolean) } + def gem_rbi_exists?(gem_name); end + sig { params(gem_name: String, version: String).returns(Pathname) } + def gem_rbi_filename(gem_name, version); end + sig { params(gem_names: T::Array[String]).returns(T::Array[Tapioca::Gemfile::Gem]) } + def gems_to_generate(gem_names); end + sig { params(eager_load: T::Boolean).void } + def load_application(eager_load:); end + sig { void } + def load_dsl_generators; end + sig { returns(Tapioca::Loader) } + def loader; end + sig { params(old_filename: Pathname, new_filename: Pathname).void } + def move(old_filename, new_filename); end + sig { void } + def perform_additions; end + sig { void } + def perform_removals; end + sig { params(command: String, reason: T.nilable(String), strictness: T.nilable(String)).returns(String) } + def rbi_header(command, reason: T.unsafe(nil), strictness: T.unsafe(nil)); end + sig { params(filename: Pathname).void } + def remove(filename); end + sig { returns(T::Array[String]) } + def removed_rbis; end + sig { void } + def require_gem_file; end + sig { params(message: String, color: T.any(Symbol, T::Array[Symbol])).void } + def say_error(message = T.unsafe(nil), *color); end +end + +Tapioca::Generator::EMPTY_RBI_COMMENT = T.let(T.unsafe(nil), String) + +class Tapioca::Loader + sig { params(gemfile: Tapioca::Gemfile).void } + def initialize(gemfile); end + + sig { params(initialize_file: T.nilable(String), require_file: T.nilable(String)).void } + def load_bundle(initialize_file, require_file); end + sig { params(environment_load: T::Boolean, eager_load: T::Boolean).void } + def load_rails(environment_load: T.unsafe(nil), eager_load: T.unsafe(nil)); end + + private + + sig { void } + def eager_load_rails_app; end + sig { returns(Tapioca::Gemfile) } + def gemfile; end + sig { void } + def load_rails_engines; end + sig { void } + def load_rake; end + sig { returns(T::Array[T.untyped]) } + def rails_engines; end + sig { void } + def require_bundle; end + sig { params(file: T.nilable(String)).void } + def require_helper(file); end + sig { params(path: String).void } + def safe_require(path); end + sig { void } + def silence_deprecations; end +end + +class Tapioca::SorbetConfig + sig { void } + def initialize; end + + def ignore; end + sig { returns(T::Array[String]) } + def paths; end + + class << self + sig { params(sorbet_config_path: String).returns(Tapioca::SorbetConfig) } + def parse_file(sorbet_config_path); end + sig { params(sorbet_config: String).returns(Tapioca::SorbetConfig) } + def parse_string(sorbet_config); end + + private + + sig { params(line: String).returns(String) } + def parse_option(line); end + end +end + +Tapioca::VERSION = T.let(T.unsafe(nil), String)
true
Other
Homebrew
brew
dcc6e7c5147b2c3a7a9cfd68bbed8dc289e93c35.json
workflows/tapioca: fetch origin/master and reset to it
.github/workflows/tapioca.yml
@@ -39,6 +39,8 @@ jobs: bundle exec tapioca sync --exclude json bundle exec srb rbi hidden-definitions + git fetch origin master + git reset --hard origin/master git checkout -B tapioca-update git add sorbet if ! git diff --no-patch --exit-code HEAD -- sorbet; then @@ -57,8 +59,6 @@ jobs: - name: Open a pull request if: steps.update.outputs.committed == 'true' - run: | - cd "$GITHUB_WORKSPACE/Library/Homebrew" - hub pull-request --no-edit + run: hub pull-request --no-edit env: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
false
Other
Homebrew
brew
dc56b53392cc005e282b470d03364b66f41808a5.json
workflows: add missing git subcommand
.github/workflows/tapioca.yml
@@ -42,7 +42,7 @@ jobs: git checkout -B tapioca-update git reset origin/master git add sorbet - if ! git --no-patch --exit-code HEAD -- sorbet; then + if ! git diff --no-patch --exit-code HEAD -- sorbet; then if ! git ls-remote --exit-code --heads origin tapioca-update; then git commit -m "sorbet: update RBI files using Tapioca." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/tapioca.yml)." echo "::set-output name=committed::true"
false
Other
Homebrew
brew
cba751a34320a57be5dfec052ffd92783399e2d4.json
docs: add sorbet documentation (cherry picked from commit 022571489a0f94ed54a0908167b553592cfe3277)
docs/README.md
@@ -46,6 +46,7 @@ - [How To Create (And Maintain) A Tap](How-to-Create-and-Maintain-a-Tap.md) - [Brew Test Bot](Brew-Test-Bot.md) - [Prose Style Guidelines](Prose-Style-Guidelines.md) +- [Type Checking with Sorbet](Typechecking.md) ## Maintainers
true
Other
Homebrew
brew
cba751a34320a57be5dfec052ffd92783399e2d4.json
docs: add sorbet documentation (cherry picked from commit 022571489a0f94ed54a0908167b553592cfe3277)
docs/Typechecking.md
@@ -0,0 +1,84 @@ +# Type Checking with Sorbet + +The majority of the code in Homebrew is written in Ruby which is a dynamic +language. To avail the benefits of static type checking, we have set up Sorbet in +our codebase which provides the benefits of static type checking to dynamic languages +like Ruby. <br> [Sorbet's Documentation](https://sorbet.org/docs/overview) is a +good place to get started if you want to dive deeper into Sorbet and it's abilities. + +## Sorbet elements in the Homebrew Codebase + +The [`sorbet/`](https://github.com/Homebrew/brew/tree/master/Library/Homebrew/sorbet) +directory in `Library/Homebrew` consists of: + +- The `rbi/` directory. It contains all Ruby Interface files, which help Sorbet to +learn about constants, ancestors, and methods defined in ways it doesn’t understand +natively. RBI files for all gems are auto-generated using +[Tapioca](https://github.com/Shopify/tapioca#tapioca). We can also create a RBI +file to help Sorbet understand dynamic definitions. +For example: Sorbet assumes that `Kernel` is not necessarily included in our modules +and classes, hence we use RBI files to explicitly include the Kernel Module. Here is an +[example](https://github.com/Homebrew/brew/blob/72419630b4658da31556a0f6ef1dfa633cf4fe4f/Library/Homebrew/sorbet/rbi/homebrew.rbi#L3-L5) +in our codebase. + +- The `config` file. It is actually a newline-separated list of arguments to pass to +`srb tc`, the same as if they’d been passed at the command line. Arguments in the config +file are always passed first (if it exists), followed by arguments provided on the +command line. We use it ignore the `Library/Homebrew/vendor` directory, which +contains gem definitions which we do not wish to type check. + +- The `files.yaml` file. It contains a list of every Ruby file in the codebase +divided into 3 strictness levels, false, true and strict. The `false` files only +report errors related to the syntax, constant resolution and correctness of the +method signatures, and not type errors. We use this file to override strictness +on a file-by-file basis. Our longtime goal is to move all `false` files to `true` +and start reporting type errors on those files as well. If you are making changes +that require adding a new ruby file, we would urge you to add it to `true` and work +out the resulting type errors. Read more about Sorbet's strictness levels +[here](https://sorbet.org/docs/static#file-level-granularity-strictness-levels). + +## Using `brew typecheck` + +When run without any arguments, `brew typecheck`, will run considering the strictness levels +set in the `files.yaml` file. However, when typecheck is run on a specific file +or directory, more errors may show up since Sorbet can not resolve constants defined +outside the scope of the specified file. These problems can be solved with RBI files. +Currently `brew typecheck` provides `quiet`, `--file`, `--dir` and `--ignore` options +but you can explore more options with `srb tc --help` and passing them with `srb tc`. + +## Resolving Type Errors + +Sorbet reports type errors along with an error reference code, which can be used +to look up more information on how to debug the error, or what causes the error in +the Sorbet documentation. Here is how we debug some common type errors: + +* Using `T.reveal_type`. In files which are `true` or higher, if we wrap a variable +or method call in `T.reveal_type`, Sorbet will show us what type it thinks that +variable has in the output of `srb tc`. This is particularly useful when writing +[method signatures](https://sorbet.org/docs/sigs) and debugging. Make sure to +remove this line from your code before committing your changes, since this is +just a debugging tool. + +* One of the most frequent errors that we've encountered is: `7003: Method does not exist.` +Since Ruby is a very dynamic language, methods can be defined in ways Sorbet cannot +see statically. In such cases, check if the method exists at runtime, if not, then +Sorbet has caught a future bug! But, it is also possible that even though a method +exists at runtime, Sorbet cannot see it. In such cases, we use `*.rbi` files. +Read more about RBI files [here](https://sorbet.org/docs/rbi). + +* Since Sorbet does not automatically assume that Kernel is to be included in Modules, +we may encounter many errors while trying to use methods like `puts`, `ohai`, `odebug` et cetera. +A simple workaround for this would be to add an extra `include Kernel` line in the +respective RBI file. + +* The tips above are very generic and apply to lots of cases. For some common gotchas +when using Sorbet, refer to the [Sorbet Error Reference](https://sorbet.org/docs/error-reference) +and [FAQ](https://sorbet.org/docs/faq). + +## Method Signatures + +Detailed explanation about why we use Method Signatures and its syntax can be found +[here](https://sorbet.org/docs/sigs). The only extra thing to keep in mind is that +we add method signatures to RBI files instead of the actual method definition in +the code. This way we preserve the original code structure and everything related to +Sorbet is kept within the `Library/Homebrew/sorbet` directory.
true
Other
Homebrew
brew
982c7adaf2227ab2f47986117337d21b30a2e65e.json
.github/workflows: add action to update tapioca definitions - Tapioca is a companion gem to Sorbet that generates RBI files for the Ruby gems in a project. - Whenever Dependabot updates a gem, Tapioca has to regenerate that gem's RBI files so that Sorbet can accurately assess the state of the typing of a codebase. - We also must regenerate Sorbet's view of [things defined at runtime](https://sorbet.org/docs/rbi#the-hidden-definition-rbi): this is what it calls `hidden-definitions`. - Obviously, this got tedious to do manually. So here's an Action that runs every three days and raises a PR if there are any changes. Co-authored-by: Vidushee Amoli <vidushee.amoli@gmail.com> Co-authored-by: Issy Long <me@issyl0.co.uk> Co-authored-by: Jonathan Chang <jchang641@gmail.com> Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
.github/workflows/tapioca-update.yml
@@ -0,0 +1,57 @@ +name: Tapioca Update +on: + push: + paths: + - .github/workflows/tapioca-update.yml + schedule: + - cron: '0 0 */3 * *' # every three days +env: + HOMEBREW_SORBET: 1 +jobs: + update-tapioca: + if: github.repository == 'Homebrew/brew' + runs-on: ubuntu-latest + steps: + - name: Set up Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@master + + - name: Configure Git user + uses: Homebrew/actions/git-user-config@master + with: + username: BrewTestBot + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6.3 + + - name: Update Tapioca Definitions + run: | + cd "$GITHUB_WORKSPACE/Library/Homebrew" + bundle install + bundle exec tapioca sync --exclude json + bundle exec srb rbi hidden-definitions + if ! git diff --exit-code -- sorbet; then + BRANCH="tapioca-update" + if ! git ls-remote --exit-code --heads origin "$BRANCH"; then + git checkout -b "$BRANCH" + git commit -am "sorbet: Update gem RBI files using Tapioca + + Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/actions?query=workflow%3A%22Tapioca+Update%22)." + fi + fi + + - name: Push commits + uses: Homebrew/actions/git-try-push@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: tapioca-update + directory: Library/Homebrew/ + + - name: Open a PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd "$GITHUB_WORKSPACE/Library/Homebrew" + hub pull-request -m "$(git log -1 --format='%s')"
false
Other
Homebrew
brew
e8143e5de7726a4ba4c1fd5e82d4b3ab5f5dff9a.json
cask/exceptions: fix super calls. Ensure that we always pass no arguments here.
Library/Homebrew/cask/exceptions.rb
@@ -5,7 +5,7 @@ class CaskError < RuntimeError; end class MultipleCaskErrors < CaskError def initialize(errors) - super + super() @errors = errors end @@ -172,7 +172,7 @@ class CaskQuarantineError < CaskError attr_reader :path, :reason def initialize(path, reason) - super + super() @path = path @reason = reason
false
Other
Homebrew
brew
d530cf68078d3b60f12032a606e5f319a4052288.json
utils/pypi: add salt to blocklist
Library/Homebrew/utils/pypi.rb
@@ -14,6 +14,7 @@ module PyPI dxpy ipython molecule + salt xonsh ].freeze
false
Other
Homebrew
brew
86eca5ab4487f79b2f1c60645cca440d4bd068aa.json
test/os/mac: add tests to validate library versions
Library/Homebrew/test/os/mac/pkgconfig_spec.rb
@@ -0,0 +1,126 @@ +# frozen_string_literal: true + +# These tests assume the needed SDKs are correctly installed, i.e. `brew doctor` passes. +# The CLT version installed should be the latest available for the running OS. +# The tests do not check other OS versions beyond than the one the tests are being run on. +# +# It is not possible to automatically check the following libraries for version updates: +# +# - libedit (incorrect LIBEDIT_MAJOR/MINOR in histedit.h) +# - uuid (not a standalone library) +# +# Additionally, libffi version detection cannot be performed on systems running Mojave or earlier. +# +# For indeterminable cases, consult https://opensource.apple.com for the version used. +describe "pkg-config" do + def pc_version(library) + path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.version}/#{library}.pc" + version = File.foreach(path) + .lazy + .grep(/^Version:\s*?(.+)$/) { Regexp.last_match(1) } + .first + .strip + if (match = version.match(/^\${(.+?)}$/)) + version = File.foreach(path) + .lazy + .grep(/^#{match.captures.first}\s*?=\s*?(.+)$/) { Regexp.last_match(1) } + .first + .strip + end + version + end + + let(:sdk) { MacOS.sdk_path_if_needed } + + it "returns the correct version for expat" do + version = File.foreach("#{sdk}/usr/include/expat.h") + .lazy + .grep(/^#define XML_(MAJOR|MINOR|MICRO)_VERSION (\d+)$/) do + { Regexp.last_match(1).downcase => Regexp.last_match(2) } + end + .inject(:merge!) + version = "#{version["major"]}.#{version["minor"]}.#{version["micro"]}" + + expect(pc_version("expat")).to eq(version) + end + + it "returns the correct version for libcurl" do + version = File.foreach("#{sdk}/usr/include/curl/curlver.h") + .lazy + .grep(/^#define LIBCURL_VERSION "(.*?)"$/) { Regexp.last_match(1) } + .first + + expect(pc_version("libcurl")).to eq(version) + end + + it "returns the correct version for libexslt" do + version = File.foreach("#{sdk}/usr/include/libexslt/exsltconfig.h") + .lazy + .grep(/^#define LIBEXSLT_VERSION (\d+)$/) { Regexp.last_match(1) } + .first + .rjust(6, "0") + version = "#{version[-6..-5].to_i}.#{version[-4..-3].to_i}.#{version[-2..].to_i}" + + expect(pc_version("libexslt")).to eq(version) + end + + it "returns the correct version for libffi" do + version = File.foreach("#{sdk}/usr/include/ffi/ffi.h") + .lazy + .grep(/^\s*libffi (\S+) - Copyright /) { Regexp.last_match(1) } + .first + + skip "Cannot detect system libffi version." if version == "PyOBJC" + + expect(pc_version("libffi")).to eq(version) + end + + it "returns the correct version for libxml-2.0" do + version = File.foreach("#{sdk}/usr/include/libxml2/libxml/xmlversion.h") + .lazy + .grep(/^#define LIBXML_DOTTED_VERSION "(.*?)"$/) { Regexp.last_match(1) } + .first + + expect(pc_version("libxml-2.0")).to eq(version) + end + + it "returns the correct version for libxslt" do + version = File.foreach("#{sdk}/usr/include/libxslt/xsltconfig.h") + .lazy + .grep(/^#define LIBXSLT_DOTTED_VERSION "(.*?)"$/) { Regexp.last_match(1) } + .first + + expect(pc_version("libxslt")).to eq(version) + end + + it "returns the correct version for ncurses" do + version = File.foreach("#{sdk}/usr/include/ncurses.h") + .lazy + .grep(/^#define NCURSES_VERSION_(MAJOR|MINOR|PATCH) (\d+)$/) do + { Regexp.last_match(1).downcase => Regexp.last_match(2) } + end + .inject(:merge!) + version = "#{version["major"]}.#{version["minor"]}.#{version["patch"]}" + + expect(pc_version("ncurses")).to eq(version) + expect(pc_version("ncursesw")).to eq(version) + end + + it "returns the correct version for sqlite3" do + version = File.foreach("#{sdk}/usr/include/sqlite3.h") + .lazy + .grep(/^#define SQLITE_VERSION\s+?"(.*?)"$/) { Regexp.last_match(1) } + .first + + expect(pc_version("sqlite3")).to eq(version) + end + + it "returns the correct version for zlib" do + version = File.foreach("#{sdk}/usr/include/zlib.h") + .lazy + .grep(/^#define ZLIB_VERSION "(.*?)"$/) { Regexp.last_match(1) } + .first + + expect(pc_version("zlib")).to eq(version) + end +end
false
Other
Homebrew
brew
57c02af359a948aef5e1bbf3d74b82395c0b7287.json
Add template titles
.github/ISSUE_TEMPLATE/bug.md
@@ -4,6 +4,8 @@ about: "If you're sure it's reproducible and not just your machine: submit an is --- +# Bug report + **Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.** - [ ] ran `brew update` and can still reproduce the problem?
true
Other
Homebrew
brew
57c02af359a948aef5e1bbf3d74b82395c0b7287.json
Add template titles
.github/ISSUE_TEMPLATE/feature.md
@@ -4,6 +4,8 @@ about: Request our thoughts on your suggestion for a new feature for Homebrew. --- +# Feature suggestion + **Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.** <!-- Please fill these sections with the relevant information: -->
true
Other
Homebrew
brew
6eb07d70f04d67345934764bb4316c8af43d5cb1.json
formula: convert license array to hash
Library/Homebrew/formula.rb
@@ -2232,7 +2232,14 @@ def method_added(method) # <pre>license all_of: ["MIT", "GPL-2.0-only"]</pre> # <pre>license "GPL-2.0-only" => { with: "LLVM-exception" }</pre> # <pre>license :public_domain</pre> - attr_rw :license + def license(args = nil) + if args.nil? + @licenses + else + args = { any_of: args } if args.is_a? Array + @licenses = args + end + end # @!attribute [w] homepage # The homepage for the software. Used by users to get more information
true
Other
Homebrew
brew
6eb07d70f04d67345934764bb4316c8af43d5cb1.json
formula: convert license array to hash
Library/Homebrew/test/utils/spdx_spec.rb
@@ -167,10 +167,6 @@ expect(described_class.license_expression_to_string(any_of: ["MIT", "EPL-1.0+"])).to eq "MIT or EPL-1.0+" end - it "treats array as any_of:" do - expect(described_class.license_expression_to_string(["MIT", "EPL-1.0+"])).to eq "MIT or EPL-1.0+" - end - it "returns license and exception" do license_expression = { "MIT" => { with: "LLVM-exception" } } expect(described_class.license_expression_to_string(license_expression)).to eq "MIT with LLVM-exception" @@ -237,7 +233,6 @@ } } let(:any_of_license) { { any_of: ["MIT", "0BSD"] } } - let(:license_array) { ["MIT", "0BSD"] } let(:all_of_license) { { all_of: ["MIT", "0BSD"] } } let(:nested_licenses) { { @@ -278,14 +273,6 @@ expect(described_class.licenses_forbid_installation?(any_of_license, multiple_forbidden)).to eq true end - it "allows installation when one of the array licenses is allowed" do - expect(described_class.licenses_forbid_installation?(license_array, mit_forbidden)).to eq false - end - - it "forbids installation when none of the array licenses are allowed" do - expect(described_class.licenses_forbid_installation?(license_array, multiple_forbidden)).to eq true - end - it "forbids installation when one of the all_of licenses is allowed" do expect(described_class.licenses_forbid_installation?(all_of_license, mit_forbidden)).to eq true end
true
Other
Homebrew
brew
6eb07d70f04d67345934764bb4316c8af43d5cb1.json
formula: convert license array to hash
Library/Homebrew/utils/spdx.rb
@@ -83,8 +83,7 @@ def license_expression_to_string(license_expression, bracket: false, hash_type: license_expression when :public_domain "Public Domain" - when Hash, Array - license_expression = { any_of: license_expression } if license_expression.is_a? Array + when Hash expressions = [] if license_expression.keys.length == 1 @@ -135,8 +134,7 @@ def licenses_forbid_installation?(license_expression, forbidden_licenses) case license_expression when String, Symbol forbidden_licenses_include? license_expression.to_s, forbidden_licenses - when Hash, Array - license_expression = { any_of: license_expression } if license_expression.is_a? Array + when Hash key = license_expression.keys.first case key when :any_of
true
Other
Homebrew
brew
2ed4196d73f407833e09ae3565506a80ef6ec485.json
cmd/update-report: fix output of new casks
Library/Homebrew/cmd/update-report.rb
@@ -466,7 +466,7 @@ def dump_formula_report(key, title) when :A name unless installed?(name) when :AC - name unless cask_installed?(name) + name.split("/").last unless cask_installed?(name) when :MC, :DC name = name.split("/").last cask_installed?(name) ? pretty_installed(name) : name
false
Other
Homebrew
brew
1f7df4881232246409be800783a59fce6d377483.json
audit: remove redundant check Co-authored-by: Rylan Polster <rslpolster@gmail.com>
Library/Homebrew/dev-cmd/audit.rb
@@ -399,7 +399,7 @@ def audit_license github_license = GitHub.get_repo_license(user, repo) return unless github_license - return if github_license && (licenses + ["NOASSERTION"]).include?(github_license) + return if (licenses + ["NOASSERTION"]).include?(github_license) return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| licenses.include? license } return if PERMITTED_FORMULA_LICENSE_MISMATCHES[formula.name] == formula.version
false
Other
Homebrew
brew
77d25da5e5420d2e17c721f010cc06704d1d20d5.json
Fix missing methods in cask DSL.
Library/Homebrew/cask/dsl.rb
@@ -282,6 +282,10 @@ def auto_updates(auto_updates = nil) end end + def respond_to_missing?(*) + super + end + def method_missing(method, *) if method Utils.method_missing_message(method, token) @@ -291,10 +295,6 @@ def method_missing(method, *) end end - def respond_to_missing?(*) - super || true - end - def appdir cask.config.appdir end
true
Other
Homebrew
brew
77d25da5e5420d2e17c721f010cc06704d1d20d5.json
Fix missing methods in cask DSL.
Library/Homebrew/cask/dsl/base.rb
@@ -18,6 +18,10 @@ def system_command(executable, **options) @command.run!(executable, **options) end + def respond_to_missing?(*) + super + end + def method_missing(method, *) if method underscored_class = self.class.name.gsub(/([[:lower:]])([[:upper:]][[:lower:]])/, '\1_\2').downcase @@ -28,10 +32,6 @@ def method_missing(method, *) super end end - - def respond_to_missing?(*) - super || true - end end end end
true
Other
Homebrew
brew
77d25da5e5420d2e17c721f010cc06704d1d20d5.json
Fix missing methods in cask DSL.
Library/Homebrew/cask/utils.rb
@@ -80,12 +80,11 @@ def self.error_message_with_suggestions end def self.method_missing_message(method, token, section = nil) - poo = [] - poo << "Unexpected method '#{method}' called" - poo << "during #{section}" if section - poo << "on Cask #{token}." + message = +"Unexpected method '#{method}' called " + message << "during #{section} " if section + message << "on Cask #{token}." - opoo("#{poo.join(" ")}\n#{error_message_with_suggestions}") + opoo "#{message}\n#{error_message_with_suggestions}" end end end
true
Other
Homebrew
brew
d45701cf9b6d369049053c675883b4178541f277.json
Switch `greedy` argument to a keyword The `greedy` parameter was switched to a keyword parameter in 3a91c37e66661781a236422c4ab8fc597e09a7a1 but this call wasn't updated accordingly.
Library/Homebrew/cmd/outdated.rb
@@ -197,7 +197,7 @@ def select_outdated(formulae_or_casks, args:) if formula_or_cask.is_a?(Formula) formula_or_cask.outdated?(fetch_head: args.fetch_HEAD?) else - formula_or_cask.outdated?(args.greedy?) + formula_or_cask.outdated?(greedy: args.greedy?) end end end
false
Other
Homebrew
brew
e215b3df75bbc355e0e1872258055ab270db4844.json
dev-cmd/audit: update license checks to new style
Library/Homebrew/dev-cmd/audit.rb
@@ -119,18 +119,20 @@ def audit # Check style in a single batch run up front for performance style_results = Style.check_style_json(style_files, options) if style_files # load licenses - spdx_data = SPDX.spdx_data + spdx_license_data = SPDX.license_data + spdx_exception_data = SPDX.exception_data new_formula_problem_lines = [] audit_formulae.sort.each do |f| only = only_cops ? ["style"] : args.only options = { - new_formula: new_formula, - strict: strict, - online: online, - git: git, - only: only, - except: args.except, - spdx_data: spdx_data, + new_formula: new_formula, + strict: strict, + online: online, + git: git, + only: only, + except: args.except, + spdx_license_data: spdx_license_data, + spdx_exception_data: spdx_exception_data, } options[:style_offenses] = style_results.file_offenses(f.path) if style_results options[:display_cop_names] = args.display_cop_names? @@ -228,7 +230,8 @@ def initialize(formula, options = {}) @new_formula_problems = [] @text = FormulaText.new(formula.path) @specs = %w[stable devel head].map { |s| formula.send(s) }.compact - @spdx_data = options[:spdx_data] + @spdx_license_data = options[:spdx_license_data] + @spdx_exception_data = options[:spdx_exception_data] end def audit_style @@ -357,43 +360,49 @@ def audit_formula_name def audit_license if formula.license.present? - non_standard_licenses = formula.license.map do |license| - next if license == :public_domain - next if @spdx_data["licenses"].any? { |spdx| spdx["licenseId"] == license } - - license - end.compact + licenses, exceptions = SPDX.parse_license_expression formula.license + non_standard_licenses = licenses.reject { |license| SPDX.valid_license? license } if non_standard_licenses.present? - problem "Formula #{formula.name} contains non-standard SPDX licenses: #{non_standard_licenses}." + problem <<~EOS + Formula #{formula.name} contains non-standard SPDX licenses: #{non_standard_licenses}. + For a list of valid licenses check: #{Formatter.url("https://spdx.org/licenses/")} + EOS end if @strict - deprecated_licenses = formula.license.map do |license| - next if license == :public_domain - next if @spdx_data["licenses"].any? do |spdx| - spdx["licenseId"] == license && !spdx["isDeprecatedLicenseId"] - end - - license - end.compact - + deprecated_licenses = licenses.select do |license| + SPDX.deprecated_license? license + end if deprecated_licenses.present? - problem "Formula #{formula.name} contains deprecated SPDX licenses: #{deprecated_licenses}." + problem <<~EOS + Formula #{formula.name} contains deprecated SPDX licenses: #{deprecated_licenses}. + You may need to add `-only` or `-or-later` for GNU licenses (e.g. `GPL`, `LGPL`, `AGPL`, `GFDL`). + For a list of valid licenses check: #{Formatter.url("https://spdx.org/licenses/")} + EOS end end + invalid_exceptions = exceptions.reject { |exception| SPDX.valid_license_exception? exception } + if invalid_exceptions.present? + problem <<~EOS + Formula #{formula.name} contains invalid or deprecated SPDX license exceptions: #{invalid_exceptions}. + For a list of valid license exceptions check: + #{Formatter.url("https://spdx.org/licenses/exceptions-index.html/")} + EOS + end + return unless @online user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) return if user.blank? github_license = GitHub.get_repo_license(user, repo) - return if github_license && (formula.license + ["NOASSERTION"]).include?(github_license) - return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| formula.license.include? license } + return if github_license && (licenses + ["NOASSERTION"]).include?(github_license) + return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| licenses.include? license } return if PERMITTED_FORMULA_LICENSE_MISMATCHES[formula.name] == formula.version - problem "Formula license #{formula.license} does not match GitHub license #{Array(github_license)}." + problem "Formula license #{licenses} does not match GitHub license #{Array(github_license)}." elsif @new_formula && @core_tap problem "Formulae in homebrew/core must specify a license."
true
Other
Homebrew
brew
e215b3df75bbc355e0e1872258055ab270db4844.json
dev-cmd/audit: update license checks to new style
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -3,6 +3,7 @@ require "dev-cmd/audit" require "formulary" require "cmd/shared_examples/args_parse" +require "utils/spdx" describe "Homebrew.audit_args" do it_behaves_like "parseable arguments" @@ -80,20 +81,21 @@ class Foo < Formula end describe "#audit_license" do - let(:spdx_data) { - JSON.parse Pathname(File.join(File.dirname(__FILE__), "../../data/spdx.json")).read - } + let(:spdx_license_data) { SPDX.license_data } + let(:spdx_exception_data) { SPDX.exception_data } - let(:custom_spdx_id) { "zzz" } let(:deprecated_spdx_id) { "GPL-1.0" } - let(:standard_mismatch_spdx_id) { "0BSD" } - let(:license_array) { ["0BSD", "GPL-3.0"] } - let(:license_array_mismatch) { ["0BSD", "MIT"] } - let(:license_array_nonstandard) { ["0BSD", "zzz", "MIT"] } - let(:license_array_deprecated) { ["0BSD", "GPL-1.0", "MIT"] } + let(:license_all_custom_id) { 'all_of: ["MIT", "zzz"]' } + let(:deprecated_spdx_exception) { "Nokia-Qt-exception-1.1" } + let(:license_any) { 'any_of: ["0BSD", "GPL-3.0-only"]' } + let(:license_any_with_plus) { 'any_of: ["0BSD+", "GPL-3.0-only"]' } + let(:license_nested_conditions) { 'any_of: ["0BSD", { all_of: ["GPL-3.0-only", "MIT"] }]' } + let(:license_any_mismatch) { 'any_of: ["0BSD", "MIT"]' } + let(:license_any_nonstandard) { 'any_of: ["0BSD", "zzz", "MIT"]' } + let(:license_any_deprecated) { 'any_of: ["0BSD", "GPL-1.0", "MIT"]' } it "does not check if the formula is not a new formula" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: false + fa = formula_auditor "foo", <<~RUBY, new_formula: false class Foo < Formula url "https://brew.sh/foo-1.0.tgz" end @@ -104,7 +106,7 @@ class Foo < Formula end it "detects no license info" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true, core_tap: true + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true, core_tap: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" end @@ -115,55 +117,84 @@ class Foo < Formula end it "detects if license is not a standard spdx-id" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" - license "#{custom_spdx_id}" + license "zzz" end RUBY fa.audit_license - expect(fa.problems.first).to match "Formula foo contains non-standard SPDX licenses: [\"zzz\"]." + expect(fa.problems.first).to match <<~EOS + Formula foo contains non-standard SPDX licenses: ["zzz"]. + For a list of valid licenses check: https://spdx.org/licenses/ + EOS end it "detects if license is a deprecated spdx-id" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true, strict: true + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true, strict: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" license "#{deprecated_spdx_id}" end RUBY fa.audit_license - expect(fa.problems.first).to match "Formula foo contains deprecated SPDX licenses: [\"GPL-1.0\"]." + expect(fa.problems.first).to match <<~EOS + Formula foo contains deprecated SPDX licenses: ["GPL-1.0"]. + You may need to add `-only` or `-or-later` for GNU licenses (e.g. `GPL`, `LGPL`, `AGPL`, `GFDL`). + For a list of valid licenses check: https://spdx.org/licenses/ + EOS + end + + it "detects if license with AND contains a non-standard spdx-id" do + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license #{license_all_custom_id} + end + RUBY + + fa.audit_license + expect(fa.problems.first).to match <<~EOS + Formula foo contains non-standard SPDX licenses: ["zzz"]. + For a list of valid licenses check: https://spdx.org/licenses/ + EOS end it "detects if license array contains a non-standard spdx-id" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" - license #{license_array_nonstandard} + license #{license_any_nonstandard} end RUBY fa.audit_license - expect(fa.problems.first).to match "Formula foo contains non-standard SPDX licenses: [\"zzz\"]." + expect(fa.problems.first).to match <<~EOS + Formula foo contains non-standard SPDX licenses: ["zzz"]. + For a list of valid licenses check: https://spdx.org/licenses/ + EOS end it "detects if license array contains a deprecated spdx-id" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true, strict: true + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true, strict: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" - license #{license_array_deprecated} + license #{license_any_deprecated} end RUBY fa.audit_license - expect(fa.problems.first).to match "Formula foo contains deprecated SPDX licenses: [\"GPL-1.0\"]." + expect(fa.problems.first).to match <<~EOS + Formula foo contains deprecated SPDX licenses: ["GPL-1.0"]. + You may need to add `-only` or `-or-later` for GNU licenses (e.g. `GPL`, `LGPL`, `AGPL`, `GFDL`). + For a list of valid licenses check: https://spdx.org/licenses/ + EOS end it "verifies that a license info is a standard spdx id" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" license "0BSD" @@ -174,11 +205,85 @@ class Foo < Formula expect(fa.problems).to be_empty end + it "verifies that a license info with plus is a standard spdx id" do + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license "0BSD+" + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end + + it "allows :public_domain license" do + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license :public_domain + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end + + it "verifies that a license info with multiple licenses are standard spdx ids" do + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license any_of: ["0BSD", "MIT"] + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end + + it "verifies that a license info with exceptions are standard spdx ids" do + formula_text = <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license "Apache-2.0" => { with: "LLVM-exception" } + end + RUBY + fa = formula_auditor "foo", formula_text, new_formula: true, + spdx_license_data: spdx_license_data, spdx_exception_data: spdx_exception_data + + fa.audit_license + expect(fa.problems).to be_empty + end + it "verifies that a license array contains only standard spdx id" do - fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license #{license_any} + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end + + it "verifies that a license array contains only standard spdx id with plus" do + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" - license #{license_array} + license #{license_any_with_plus} + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end + + it "verifies that a license array with AND contains only standard spdx ids" do + fa = formula_auditor "foo", <<~RUBY, spdx_license_data: spdx_license_data, new_formula: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license #{license_nested_conditions} end RUBY @@ -188,21 +293,93 @@ class Foo < Formula it "checks online and verifies that a standard license id is the same "\ "as what is indicated on its Github repo" do - fa = formula_auditor "cask", <<~RUBY, spdx_data: spdx_data, online: true, core_tap: true, new_formula: true + formula_text = <<~RUBY class Cask < Formula url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" head "https://github.com/cask/cask.git" license "GPL-3.0" end RUBY + fa = formula_auditor "cask", formula_text, spdx_license_data: spdx_license_data, + online: true, core_tap: true, new_formula: true + + fa.audit_license + expect(fa.problems).to be_empty + end + + it "checks online and verifies that a standard license id with AND is the same "\ + "as what is indicated on its Github repo" do + formula_text = <<~RUBY + class Cask < Formula + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license all_of: ["GPL-3.0-or-later", "MIT"] + end + RUBY + fa = formula_auditor "cask", formula_text, spdx_license_data: spdx_license_data, + online: true, core_tap: true, new_formula: true + + fa.audit_license + expect(fa.problems).to be_empty + end + + it "checks online and verifies that a standard license id with WITH is the same "\ + "as what is indicated on its Github repo" do + formula_text = <<~RUBY + class Cask < Formula + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license "GPL-3.0-or-later" => { with: "LLVM-exception" } + end + RUBY + fa = formula_auditor "cask", formula_text, online: true, core_tap: true, new_formula: true, + spdx_license_data: spdx_license_data, spdx_exception_data: spdx_exception_data fa.audit_license expect(fa.problems).to be_empty end + it "verifies that a license exception has standard spdx ids" do + formula_text = <<~RUBY + class Cask < Formula + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license "GPL-3.0-or-later" => { with: "zzz" } + end + RUBY + fa = formula_auditor "cask", formula_text, core_tap: true, new_formula: true, + spdx_license_data: spdx_license_data, spdx_exception_data: spdx_exception_data + + fa.audit_license + expect(fa.problems.first).to match <<~EOS + Formula cask contains invalid or deprecated SPDX license exceptions: ["zzz"]. + For a list of valid license exceptions check: + https://spdx.org/licenses/exceptions-index.html/ + EOS + end + + it "verifies that a license exception has non-deprecated spdx ids" do + formula_text = <<~RUBY + class Cask < Formula + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license "GPL-3.0-or-later" => { with: "#{deprecated_spdx_exception}" } + end + RUBY + fa = formula_auditor "cask", formula_text, core_tap: true, new_formula: true, + spdx_license_data: spdx_license_data, spdx_exception_data: spdx_exception_data + + fa.audit_license + expect(fa.problems.first).to match <<~EOS + Formula cask contains invalid or deprecated SPDX license exceptions: ["#{deprecated_spdx_exception}"]. + For a list of valid license exceptions check: + https://spdx.org/licenses/exceptions-index.html/ + EOS + end + it "checks online and verifies that a standard license id is in the same exempted license group" \ "as what is indicated on its GitHub repo" do - fa = formula_auditor "cask", <<~RUBY, spdx_data: spdx_data, online: true, new_formula: true + fa = formula_auditor "cask", <<~RUBY, spdx_license_data: spdx_license_data, online: true, new_formula: true class Cask < Formula url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" head "https://github.com/cask/cask.git" @@ -216,11 +393,11 @@ class Cask < Formula it "checks online and verifies that a standard license array is in the same exempted license group" \ "as what is indicated on its GitHub repo" do - fa = formula_auditor "cask", <<~RUBY, spdx_data: spdx_data, online: true, new_formula: true + fa = formula_auditor "cask", <<~RUBY, spdx_license_data: spdx_license_data, online: true, new_formula: true class Cask < Formula url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" head "https://github.com/cask/cask.git" - license ["GPL-3.0-or-later", "MIT"] + license any_of: ["GPL-3.0-or-later", "MIT"] end RUBY @@ -230,43 +407,48 @@ class Cask < Formula it "checks online and detects that a formula-specified license is not "\ "the same as what is indicated on its Github repository" do - fa = formula_auditor "cask", <<~RUBY, online: true, spdx_data: spdx_data, core_tap: true, new_formula: true + formula_text = <<~RUBY class Cask < Formula url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" head "https://github.com/cask/cask.git" - license "#{standard_mismatch_spdx_id}" + license "0BSD" end RUBY + fa = formula_auditor "cask", formula_text, spdx_license_data: spdx_license_data, + online: true, core_tap: true, new_formula: true fa.audit_license - expect(fa.problems.first).to match "Formula license #{Array(standard_mismatch_spdx_id)} "\ - "does not match GitHub license [\"GPL-3.0\"]." + expect(fa.problems.first).to match "Formula license [\"0BSD\"] does not match GitHub license [\"GPL-3.0\"]." end it "checks online and detects that an array of license does not contain "\ "what is indicated on its Github repository" do - fa = formula_auditor "cask", <<~RUBY, online: true, spdx_data: spdx_data, core_tap: true, new_formula: true + formula_text = <<~RUBY class Cask < Formula url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" head "https://github.com/cask/cask.git" - license #{license_array_mismatch} + license #{license_any_mismatch} end RUBY + fa = formula_auditor "cask", formula_text, spdx_license_data: spdx_license_data, + online: true, core_tap: true, new_formula: true fa.audit_license - expect(fa.problems.first).to match "Formula license #{license_array_mismatch} "\ + expect(fa.problems.first).to match "Formula license [\"0BSD\", \"MIT\"] "\ "does not match GitHub license [\"GPL-3.0\"]." end it "checks online and verifies that an array of license contains "\ "what is indicated on its Github repository" do - fa = formula_auditor "cask", <<~RUBY, online: true, spdx_data: spdx_data, core_tap: true, new_formula: true + formula_text = <<~RUBY class Cask < Formula url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" head "https://github.com/cask/cask.git" - license #{license_array} + license #{license_any} end RUBY + fa = formula_auditor "cask", formula_text, spdx_license_data: spdx_license_data, + online: true, core_tap: true, new_formula: true fa.audit_license expect(fa.problems).to be_empty
true
Other
Homebrew
brew
60ec30d41eeee3ea71e8d0755f41d2780aae2052.json
formula: update license specification
Library/.rubocop.yml
@@ -68,6 +68,10 @@ Style/HashTransformKeys: Style/HashTransformValues: Enabled: true +# Allow for license expressions +Style/HashAsLastArrayItem: + Enabled: false + # Enabled now LineLength is lowish. Style/IfUnlessModifier: Enabled: true
true
Other
Homebrew
brew
60ec30d41eeee3ea71e8d0755f41d2780aae2052.json
formula: update license specification
Library/Homebrew/.rubocop.yml
@@ -61,6 +61,8 @@ Metrics/MethodLength: Metrics/ModuleLength: Enabled: true Max: 600 + Exclude: + - 'test/**/*' Metrics/PerceivedComplexity: Enabled: true Max: 90 @@ -143,3 +145,9 @@ Style/GuardClause: # so many of these in formulae but none in here Style/StringConcatenation: Enabled: true + +# don't want this for formulae but re-enabled for Library/Homebrew +Style/HashAsLastArrayItem: + Enabled: true + Exclude: + - 'test/utils/spdx_spec.rb'
true
Other
Homebrew
brew
60ec30d41eeee3ea71e8d0755f41d2780aae2052.json
formula: update license specification
Library/Homebrew/cmd/info.rb
@@ -8,6 +8,7 @@ require "keg" require "tab" require "json" +require "utils/spdx" module Homebrew module_function @@ -211,13 +212,7 @@ def info_formula(f, args:) puts "From: #{Formatter.url(github_info(f))}" - if f.license.present? - licenses = f.license - .map(&:to_s) - .join(", ") - .sub("public_domain", "Public Domain") - puts "License: #{licenses}" - end + puts "License: #{SPDX.license_expression_to_string f.license}" if f.license.present? unless f.deps.empty? ohai "Dependencies"
true
Other
Homebrew
brew
60ec30d41eeee3ea71e8d0755f41d2780aae2052.json
formula: update license specification
Library/Homebrew/formula.rb
@@ -2219,18 +2219,20 @@ def method_added(method) # @!attribute [w] # The SPDX ID of the open-source license that the formula uses. # Shows when running `brew info`. - # Multiple licenses means that the software is licensed under multiple licenses. - # Do not use multiple licenses if e.g. different parts are under different licenses. + # Use `:any`, `:all` or `:with` to describe complex license expressions. + # `:any` should be used when the user can choose which license to use. + # `:all` should be used when the user must use all licenses. + # `:with` should be used to specify a valid SPDX exception. + # Add `+` to an identifier to indicate that the formulae can be + # licensed under later versions of the same license. + # @see https://spdx.github.io/spdx-spec/appendix-IV-SPDX-license-expressions/ SPDX license expression guide # <pre>license "BSD-2-Clause"</pre> - # <pre>license ["MIT", "GPL-2.0"]</pre> + # <pre>license "EPL-1.0+"</pre> + # <pre>license any_of: ["MIT", "GPL-2.0-only"]</pre> + # <pre>license all_of: ["MIT", "GPL-2.0-only"]</pre> + # <pre>license "GPL-2.0-only" => { with: "LLVM-exception" }</pre> # <pre>license :public_domain</pre> - def license(args = nil) - if args.nil? - @licenses - else - @licenses = Array(args) - end - end + attr_rw :license # @!attribute [w] homepage # The homepage for the software. Used by users to get more information
true
Other
Homebrew
brew
60ec30d41eeee3ea71e8d0755f41d2780aae2052.json
formula: update license specification
Library/Homebrew/formula_installer.rb
@@ -19,6 +19,7 @@ require "cask/cask_loader" require "cmd/install" require "find" +require "utils/spdx" class FormulaInstaller include FormulaCellarChecks @@ -1130,24 +1131,29 @@ def forbidden_license_check .to_s .sub("Public Domain", "public_domain") .split(" ") + .to_h do |license| + [license, SPDX.license_version_info(license)] + end + return if forbidden_licenses.blank? compute_dependencies.each do |dep, _| next if @ignore_deps dep_f = dep.to_formula - next unless dep_f.license.all? { |license| forbidden_licenses.include?(license.to_s) } + next unless SPDX.licenses_forbid_installation? dep_f.license, forbidden_licenses raise CannotInstallFormulaError, <<~EOS - The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden: #{dep_f.license}. + The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden: + #{SPDX.license_expression_to_string dep_f.license}. EOS end return if @only_deps - return unless formula.license.all? { |license| forbidden_licenses.include?(license.to_s) } + return unless SPDX.licenses_forbid_installation? formula.license, forbidden_licenses raise CannotInstallFormulaError, <<~EOS - #{formula.name}'s licenses are all forbidden: #{formula.license}. + #{formula.name}'s licenses are all forbidden: #{SPDX.license_expression_to_string formula.license}. EOS end end
true
Other
Homebrew
brew
fc7c3c923af33abf3376c7210a1a0809d512760f.json
cmd/update-reset: fix handling of multiple relative directories
Library/Homebrew/cmd/update-reset.sh
@@ -35,16 +35,15 @@ homebrew-update-reset() { for DIR in "${REPOS[@]}" do [[ -d "$DIR/.git" ]] || continue - cd "$DIR" || continue ohai "Fetching $DIR..." - git fetch --force --tags origin - git remote set-head origin --auto >/dev/null + git -C "$DIR" fetch --force --tags origin + git -C "$DIR" remote set-head origin --auto >/dev/null echo ohai "Resetting $DIR..." - head="$(git symbolic-ref refs/remotes/origin/HEAD)" + head="$(git -C "$DIR" symbolic-ref refs/remotes/origin/HEAD)" head="${head#refs/remotes/origin/}" - git checkout --force -B "$head" origin/HEAD + git -C "$DIR" checkout --force -B "$head" origin/HEAD echo done }
false
Other
Homebrew
brew
b43f17b2d0503dbec503e5a4d53441ed2eac6add.json
formula_versions: handle references to too old MacOS in formulae
Library/Homebrew/formula_versions.rb
@@ -64,6 +64,9 @@ def bottle_version_map(branch) versions_seen = (map.keys + [f.pkg_version]).uniq.length end return map if versions_seen > MAX_VERSIONS_DEPTH + rescue MacOSVersionError => e + odebug "#{e} in #{name} at revision #{rev}" if debug? + break end map end
false
Other
Homebrew
brew
afe9a48373cf2c1a423464b45a464d3971ee114b.json
Add limit to repology api
Library/Homebrew/dev-cmd/bump.rb
@@ -38,7 +38,7 @@ def bump response else - Repology.parse_api_response + Repology.parse_api_response(requested_limit) end validated_formulae = {}
true
Other
Homebrew
brew
afe9a48373cf2c1a423464b45a464d3971ee114b.json
Add limit to repology api
Library/Homebrew/utils/repology.rb
@@ -5,8 +5,6 @@ module Repology module_function - MAX_PAGINATION = 15 - def query_api(last_package_in_response = "") last_package_in_response += "/" if last_package_in_response.present? url = "https://repology.org/api/v1/projects/#{last_package_in_response}?inrepo=homebrew&outdated=1" @@ -28,25 +26,26 @@ def single_package_query(name) homebrew.empty? ? nil : { name => data } end - def parse_api_response + def parse_api_response(limit = nil) ohai "Querying outdated packages from Repology" + page_no = 1 outdated_packages = query_api - last_package_index = outdated_packages.size - 1 response_size = outdated_packages.size - page_no = 1 + last_package_index = outdated_packages.size - 1 + max_pagination = limit.nil? ? 15 : (limit.to_f / 200).ceil - while response_size > 1 && page_no <= MAX_PAGINATION + while response_size > 1 && page_no <= max_pagination odebug "Paginating Repology API page: #{page_no}" - last_package_in_response = outdated_packages.keys[last_package_index] response = query_api(last_package_in_response) response_size = response.size outdated_packages.merge!(response) last_package_index = outdated_packages.size - 1 - page_no += 1 end + + outdated_packages = outdated_packages.first(limit) if outdated_packages.size > limit puts "#{outdated_packages.size} outdated #{"package".pluralize(outdated_packages.size)} found" puts
true
Other
Homebrew
brew
e08891812843bbd732c98af1906fc843ac2712e9.json
cask home: Remove deprecation comment
Library/Homebrew/cask/cmd/home.rb
@@ -8,9 +8,6 @@ def self.description end def run - # TODO: enable for next major/minor release - # odeprecated "brew cask home", "brew home" - if casks.none? odebug "Opening project homepage" self.class.open_url "https://brew.sh/"
false
Other
Homebrew
brew
543f421702cd0feb13c30979cb157d6e85503da0.json
cask --cache: Remove deprecation comment
Library/Homebrew/cask/cmd/--cache.rb
@@ -18,9 +18,6 @@ def self.command_name end def run - # TODO: enable for next major/minor release - # odeprecated "brew cask --cache", "brew --cache --cask" - casks.each do |cask| puts self.class.cached_location(cask) end
false
Other
Homebrew
brew
b123fca2270c4cd15167e70304004d14f9cc1983.json
cask: Add TODOs to deprecate integrated cask cmds
Library/Homebrew/cask/cmd.rb
@@ -47,6 +47,16 @@ class Cmd "dr" => "doctor", }.freeze + DEPRECATED_COMMANDS = { + Cmd::Cache => "brew --cache --cask", + Cmd::Doctor => "brew doctor --verbose", + Cmd::Home => "brew home", + Cmd::List => "brew list --cask", + Cmd::Outdated => "brew outdated --cask", + Cmd::Reinstall => "brew reinstall", + Cmd::Upgrade => "brew upgrade --cask", + }.freeze + def self.description max_command_len = Cmd.commands.map(&:length).max @@ -212,6 +222,11 @@ def run detect_external_command(*argv) || [args.remaining.empty? ? NullCommand : UnknownSubcommand.new(args.remaining.first), argv] + # TODO: enable for next major/minor release + # if (replacement = DEPRECATED_COMMANDS[command]) + # odeprecated "brew cask #{command.command_name}", replacement + # end + if args.help? puts command.help else
false
Other
Homebrew
brew
b338398a8c002953d64852c51f0d7b5e9c419332.json
tab: add built_on & arch information
Library/Homebrew/development_tools.rb
@@ -99,6 +99,15 @@ def curl_handles_most_https_certificates? def subversion_handles_most_https_certificates? true end + + def build_system_info + { + "os" => ENV["HOMEBREW_SYSTEM"], + "os_version" => OS_VERSION, + "cpu_family" => Hardware::CPU.family, + } + end + alias generic_build_system_info build_system_info end end
true
Other
Homebrew
brew
b338398a8c002953d64852c51f0d7b5e9c419332.json
tab: add built_on & arch information
Library/Homebrew/extend/os/mac/development_tools.rb
@@ -56,5 +56,13 @@ def custom_installation_instructions brew install gcc EOS end + + def build_system_info + build_info = { + "xcode" => MacOS::Xcode.version.to_s.presence, + "clt" => MacOS::CLT.version.to_s.presence, + } + generic_build_system_info.merge build_info + end end end
true
Other
Homebrew
brew
b338398a8c002953d64852c51f0d7b5e9c419332.json
tab: add built_on & arch information
Library/Homebrew/tab.rb
@@ -36,6 +36,7 @@ def self.create(formula, compiler, stdlib) "stdlib" => stdlib, "aliases" => formula.aliases, "runtime_dependencies" => Tab.runtime_deps_hash(runtime_deps), + "arch" => Hardware::CPU.arch, "source" => { "path" => formula.specified_path.to_s, "tap" => formula.tap&.name, @@ -47,6 +48,7 @@ def self.create(formula, compiler, stdlib) "version_scheme" => formula.version_scheme, }, }, + "built_on" => DevelopmentTools.build_system_info, } new(attributes) @@ -198,6 +200,7 @@ def self.empty "version_scheme" => 0, }, }, + "built_on" => DevelopmentTools.generic_build_system_info, } new(attributes) @@ -344,6 +347,7 @@ def to_json(options = nil) "aliases" => aliases, "runtime_dependencies" => runtime_dependencies, "source" => source, + "built_on" => built_on, } JSON.generate(attributes, options)
true
Other
Homebrew
brew
b338398a8c002953d64852c51f0d7b5e9c419332.json
tab: add built_on & arch information
Library/Homebrew/test/caveats_spec.rb
@@ -120,7 +120,7 @@ def plist "plist_test.plist" end end - allow(ENV).to receive(:[]).with("TMUX").and_return(true) + ENV["TMUX"] = "1" allow(Homebrew).to receive(:_system).with("/usr/bin/pbpaste").and_return(false) caveats = described_class.new(f).caveats
true
Other
Homebrew
brew
dbbc14040d7acc94ca6e40c39ca60b38aa1419b0.json
extend/os/mac: install svn on catalina and newer
Library/Homebrew/extend/os/mac/dependency_collector.rb
@@ -6,7 +6,9 @@ class DependencyCollector def git_dep_if_needed(tags); end - def subversion_dep_if_needed(tags); end + def subversion_dep_if_needed(tags) + Dependency.new("subversion", tags) if MacOS.version >= :catalina + end def cvs_dep_if_needed(tags) Dependency.new("cvs", tags)
true
Other
Homebrew
brew
dbbc14040d7acc94ca6e40c39ca60b38aa1419b0.json
extend/os/mac: install svn on catalina and newer
Library/Homebrew/test/os/mac/dependency_collector_spec.rb
@@ -32,6 +32,10 @@ specify "Resource dependency from a Subversion URL" do resource = Resource.new resource.url("svn://brew.sh/foo/bar") - expect(subject.add(resource)).to be nil + if MacOS.version < :catalina + expect(subject.add(resource)).to be nil + else + expect(subject.add(resource)).not_to be nil + end end end
true
Other
Homebrew
brew
420e8fdbe4742eb655a58c7faabfca6fe200d4a8.json
pr-automerge: pluralize message only when needed
Library/Homebrew/dev-cmd/pr-automerge.rb
@@ -49,7 +49,7 @@ def pr_automerge return end - ohai "#{prs.size} matching pull requests:" + ohai "#{prs.count} matching pull #{"request".pluralize(prs.count)}:" pr_urls = [] prs.each do |pr| puts "#{tap.full_name unless tap.core_tap?}##{pr["number"]}: #{pr["title"]}"
false
Other
Homebrew
brew
db361e29b8d4909757e624fafdfb6186d0fe112a.json
check_tmpdir_executable: Remove stray undent Fix the error: Error: undefined method undent for #<String> .../extend/os/linux/diagnostic.rb:41:in check_tmpdir_executable
Library/Homebrew/extend/os/linux/diagnostic.rb
@@ -38,7 +38,7 @@ def check_tmpdir_executable f.close return if system f.path - <<~EOS.undent + <<~EOS The directory #{HOMEBREW_TEMP} does not permit executing programs. It is likely mounted as "noexec". Please set HOMEBREW_TEMP in your #{shell_profile} to a different directory, for example:
false
Other
Homebrew
brew
b63b56f4c2193c76a6a8674db36816509a7ea498.json
home: Remove warning for cask with same name
Library/Homebrew/cmd/home.rb
@@ -25,10 +25,7 @@ def home end homepages = args.formulae_and_casks.map do |formula_or_cask| - disclaimer = disclaimers(formula_or_cask) - disclaimer = " (#{disclaimer})" if disclaimer.present? - - puts "Opening homepage for #{name_of(formula_or_cask)}#{disclaimer}" + puts "Opening homepage for #{name_of(formula_or_cask)}" formula_or_cask.homepage end @@ -42,15 +39,4 @@ def name_of(formula_or_cask) "Cask #{formula_or_cask.token}" end end - - def disclaimers(formula_or_cask) - return unless formula_or_cask.is_a? Formula - - begin - cask = Cask::CaskLoader.load formula_or_cask.name - "for the cask, use #{cask.tap.name}/#{cask.token}" - rescue Cask::CaskUnavailableError - nil - end - end end
true
Other
Homebrew
brew
b63b56f4c2193c76a6a8674db36816509a7ea498.json
home: Remove warning for cask with same name
Library/Homebrew/test/cli/named_args_spec.rb
@@ -99,7 +99,6 @@ named_args = described_class.new("foo", "baz") allow(named_args).to receive(:resolve_keg).and_call_original allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg - stub_cask_loader baz, call_original: true kegs, casks = named_args.to_kegs_to_casks
true
Other
Homebrew
brew
b8d21dcf6008dafa4e9e9c2e1c56e5e1c057e1d2.json
brew.sh: handle Linux systems with no 'locale'
Library/Homebrew/brew.sh
@@ -6,15 +6,18 @@ case "$HOMEBREW_SYSTEM" in esac # Force UTF-8 to avoid encoding issues for users with broken locale settings. -if ! command -v locale >/dev/null -then - export LC_ALL=C -elif [[ "$(locale charmap)" != "UTF-8" ]] +if [[ -n "$HOMEBREW_MACOS" ]] then - if [[ -n "$HOMEBREW_MACOS" ]] + if [[ "$(locale charmap)" != "UTF-8" ]] then export LC_ALL="en_US.UTF-8" - else + fi +else + if ! command -v locale >/dev/null + then + export LC_ALL=C + elif [[ "$(locale charmap)" != "UTF-8" ]] + then locales=$(locale -a) c_utf_regex='\bC\.(utf8|UTF-8)\b' en_us_regex='\ben_US\.(utf8|UTF-8)\b'
false
Other
Homebrew
brew
dc1bbe7f81a453079d397c387cc55a53ee22eb13.json
handle requests for multiple formulae
Library/Homebrew/dev-cmd/bump.rb
@@ -23,21 +23,39 @@ def bump_args def bump args = bump_args.parse - requested_formula = args.formulae.first.to_s if args.formulae.first + requested_formulae = !args.formulae.empty? ? args.formulae.map(&:name) : nil + requested_limit = args.limit.to_i if args.limit.present? - raise FormulaUnavailableError, requested_formula if requested_formula && !validate_formula(requested_formula) + repology_data = if requested_formulae + response = {} + requested_formulae.each do |formula| + raise FormulaUnavailableError, formula unless validate_formula(formula) + + package_data = Repology.single_package_query(formula) + response[package_data.keys.first] = package_data.values.first if package_data + end - repology_data = if requested_formula - Repology.single_package_query(requested_formula) + response else Repology.parse_api_response end - validated_formulae = if repology_data.blank? - { requested_formula.to_s => Repology.format_package(requested_formula, nil) } - else - Repology.validate_and_format_packages(repology_data, requested_limit) + validated_formulae = {} + + validated_formulae = Repology.validate_and_format_packages(repology_data, requested_limit) if repology_data + + if requested_formulae + repology_excluded_formulae = requested_formulae.reject do |formula| + repology_data[formula] + end + + formulae = {} + repology_excluded_formulae.each do |formula| + formulae[formula] = Repology.format_package(formula, nil) + end + + formulae.each { |formula, data| validated_formulae[formula] = data } end display(validated_formulae)
true
Other
Homebrew
brew
dc1bbe7f81a453079d397c387cc55a53ee22eb13.json
handle requests for multiple formulae
Library/Homebrew/utils/repology.rb
@@ -58,7 +58,6 @@ def validate_and_format_packages(outdated_repology_packages, limit) packages = {} outdated_repology_packages.each do |_name, repositories| - # identify homebrew repo repology_homebrew_repo = repositories.find do |repo| repo["repo"] == "homebrew" end
true
Other
Homebrew
brew
5d38cd7296dabb5cf1a0f0065c82697b12f70229.json
cask/list: fix artifact list
Library/Homebrew/cask/cmd/list.rb
@@ -1,5 +1,7 @@ # frozen_string_literal: true +require "cask/artifact/relocated" + module Cask class Cmd class List < AbstractCommand @@ -48,17 +50,23 @@ def self.list_casks(*casks, json: false, one: false, full_name: false, versions: elsif versions puts output.map(&method(:format_versioned)) elsif !output.empty? && casks.any? - puts output.map(&method(:list_artifacts)) + output.map(&method(:list_artifacts)) elsif !output.empty? puts Formatter.columns(output.map(&:to_s)) end end def self.list_artifacts(cask) - cask.artifacts.group_by(&:class).each do |klass, artifacts| - next unless klass.respond_to?(:english_description) + cask.artifacts.group_by(&:class).sort_by { |klass, _| klass.english_name }.each do |klass, artifacts| + next if [Artifact::Uninstall, Artifact::Zap].include? klass + + ohai klass.english_name + artifacts.each do |artifact| + puts artifact.summarize_installed if artifact.respond_to?(:summarize_installed) + next if artifact.respond_to?(:summarize_installed) - return "==> #{klass.english_description}", artifacts.map(&:summarize_installed) + puts artifact + end end end
true
Other
Homebrew
brew
5d38cd7296dabb5cf1a0f0065c82697b12f70229.json
cask/list: fix artifact list
Library/Homebrew/test/cask/cmd/list_spec.rb
@@ -126,9 +126,9 @@ expect { described_class.run("local-transmission", "local-caffeine") }.to output(<<~EOS).to_stdout - ==> Apps + ==> App #{transmission.config.appdir.join("Transmission.app")} (#{transmission.config.appdir.join("Transmission.app").abv}) - ==> Apps + ==> App Missing App: #{caffeine.config.appdir.join("Caffeine.app")} EOS end
true
Other
Homebrew
brew
8fb6218d052cd7e33435ba88f3ecc38c62278e4c.json
bump-formula-pr: fix regression when formula.tap is Nil
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -105,8 +105,10 @@ def use_correct_linux_tap(formula, args:) end end end - origin_branch = Utils.popen_read("git", "-C", formula.tap.path.to_s, "symbolic-ref", "-q", "--short", - "refs/remotes/origin/HEAD").chomp.presence + if formula.tap + origin_branch = Utils.popen_read("git", "-C", formula.tap.path.to_s, "symbolic-ref", "-q", "--short", + "refs/remotes/origin/HEAD").chomp.presence + end origin_branch ||= "origin/master" [formula.tap&.full_name, origin_branch, "-"] end
false
Other
Homebrew
brew
c8016f6c0af91ed5a105ea82911259a7bff03666.json
named args: add method tests
Library/Homebrew/test/cli/named_args_spec.rb
@@ -0,0 +1,112 @@ +# frozen_string_literal: true + +require "cli/named_args" + +describe Homebrew::CLI::NamedArgs do + let(:foo) do + formula "foo" do + url "https://brew.sh" + version "1.0" + end + end + + let(:foo_keg) do + path = (HOMEBREW_CELLAR/"foo/1.0").resolved_path + mkdir_p path + Keg.new(path) + end + + let(:bar) do + formula "bar" do + url "https://brew.sh" + version "1.0" + end + end + + let(:bar_keg) do + path = (HOMEBREW_CELLAR/"bar/1.0").resolved_path + mkdir_p path + Keg.new(path) + end + + let(:baz) do + Cask::CaskLoader.load(+<<~RUBY) + cask "baz" do + version "1.0" + end + RUBY + end + + describe "#to_formulae" do + it "returns formulae" do + allow(Formulary).to receive(:loader_for).and_call_original + stub_formula_loader foo + stub_formula_loader bar + + expect(described_class.new("foo", "bar").to_formulae).to eq [foo, bar] + end + end + + describe "#to_formulae_and_casks" do + it "returns formulae and casks" do + allow(Formulary).to receive(:loader_for).and_call_original + stub_formula_loader foo + stub_cask_loader baz + + expect(described_class.new("foo", "baz").to_formulae_and_casks).to eq [foo, baz] + end + end + + describe "#to_resolved_formulae" do + it "returns resolved formulae" do + allow(Formulary).to receive(:resolve).and_return(foo, bar) + + expect(described_class.new("foo", "bar").to_resolved_formulae).to eq [foo, bar] + end + end + + describe "#to_resolved_formulae_to_casks" do + it "returns resolved formulae, as well as casks" do + allow(Formulary).to receive(:resolve).and_call_original + allow(Formulary).to receive(:resolve).with("foo", any_args).and_return foo + stub_cask_loader baz + + resolved_formulae, casks = described_class.new("foo", "baz").to_resolved_formulae_to_casks + + expect(resolved_formulae).to eq [foo] + expect(casks).to eq [baz] + end + end + + describe "#to_casks" do + it "returns casks" do + stub_cask_loader baz + + expect(described_class.new("baz").to_casks).to eq [baz] + end + end + + describe "#to_kegs" do + it "returns kegs" do + named_args = described_class.new("foo", "bar") + allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg + allow(named_args).to receive(:resolve_keg).with("bar").and_return bar_keg + + expect(named_args.to_kegs).to eq [foo_keg, bar_keg] + end + end + + describe "#to_kegs_to_casks" do + it "returns kegs, as well as casks" do + named_args = described_class.new("foo", "baz") + allow(named_args).to receive(:resolve_keg).and_call_original + allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg + stub_cask_loader baz + + kegs, casks = named_args.to_kegs_to_casks + + expect(kegs).to eq [foo_keg] + expect(casks).to eq [baz] + end + end +end
true
Other
Homebrew
brew
c8016f6c0af91ed5a105ea82911259a7bff03666.json
named args: add method tests
Library/Homebrew/test/spec_helper.rb
@@ -36,6 +36,7 @@ require_relative "../global" require "test/support/no_seed_progress_formatter" +require "test/support/helper/cask" require "test/support/helper/fixtures" require "test/support/helper/formula" require "test/support/helper/mktmpdir" @@ -86,6 +87,7 @@ config.include(RuboCop::RSpec::ExpectOffense) + config.include(Test::Helper::Cask) config.include(Test::Helper::Fixtures) config.include(Test::Helper::Formula) config.include(Test::Helper::MkTmpDir)
true
Other
Homebrew
brew
c8016f6c0af91ed5a105ea82911259a7bff03666.json
named args: add method tests
Library/Homebrew/test/support/helper/cask.rb
@@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require "cask/cask_loader" + +module Test + module Helper + module Cask + def stub_cask_loader(cask, ref = cask.token) + loader = ::Cask::CaskLoader::FromInstanceLoader.new cask + allow(::Cask::CaskLoader).to receive(:for).with(ref).and_return(loader) + end + end + end +end
true
Other
Homebrew
brew
4c833b241d3dcc1b1f1efa83dafba5c45877c5fa.json
Fix parsing of negative options.
Library/Homebrew/cli/parser.rb
@@ -73,6 +73,12 @@ def switch(*names, description: nil, env: nil, required_for: nil, depends_on: ni description = option_to_description(*names) if description.nil? process_option(*names, description) @parser.public_send(method, *names, *wrap_option_desc(description)) do |value| + value = if names.any? { |name| name.start_with?("--[no-]") } + value + else + true + end + set_switch(*names, value: value, from: :args) end
true
Other
Homebrew
brew
4c833b241d3dcc1b1f1efa83dafba5c45877c5fa.json
Fix parsing of negative options.
Library/Homebrew/test/cli/parser_spec.rb
@@ -15,7 +15,7 @@ allow(Homebrew::EnvConfig).to receive(:pry?).and_return(true) end - context "when using negative options" do + context "when using binary options" do subject(:parser) { described_class.new do switch "--[no-]positive" @@ -33,6 +33,30 @@ end end + context "when using negative options" do + subject(:parser) { + described_class.new do + switch "--no-positive" + end + } + + it "does not set the positive name" do + args = parser.parse(["--no-positive"]) + expect(args.positive?).to be nil + end + + it "fails when using the positive name" do + expect { + parser.parse(["--positive"]) + }.to raise_error(/invalid option/) + end + + it "sets the negative name to true if the negative flag is passed" do + args = parser.parse(["--no-positive"]) + expect(args.no_positive?).to be true + end + end + context "when `ignore_invalid_options` is true" do it "passes through invalid options" do args = parser.parse(["-v", "named-arg", "--not-a-valid-option"], ignore_invalid_options: true)
true
Other
Homebrew
brew
8df618958dbd459715f3d5ee6456092f4fec59af.json
bump-formula-pr: add warnings for patches and resources
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -133,6 +133,9 @@ def bump_formula_pr new_version = args.version check_closed_pull_requests(formula, tap_full_name, version: new_version, args: args) if new_version + opoo "This formula has patches that may be resolved upstream." if formula.patchlist.present? + opoo "This formula has resources that may need to be updated." if formula.resources.present? + requested_spec = :stable formula_spec = formula.stable odie "#{formula}: no #{requested_spec} specification found!" unless formula_spec
false
Other
Homebrew
brew
c983d85eea9d9579bfb8685c0e1fc73651cb8175.json
bump-formula-pr: add `determine_mirror` helper method
Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -145,16 +145,7 @@ def bump_formula_pr new_tag = args.tag new_revision = args.revision new_mirrors ||= args.mirror - new_mirror ||= case new_url - when %r{.*ftp.gnu.org/gnu.*} - new_url.sub "ftp.gnu.org/gnu", "ftpmirror.gnu.org" - when %r{.*download.savannah.gnu.org/*} - new_url.sub "download.savannah.gnu.org", "download-mirror.savannah.gnu.org" - when %r{.*www.apache.org/dyn/closer.lua\?path=.*} - new_url.sub "www.apache.org/dyn/closer.lua?path=", "archive.apache.org/dist/" - when %r{.*mirrors.ocf.berkeley.edu/debian.*} - new_url.sub "mirrors.ocf.berkeley.edu/debian", "mirrorservice.org/sites/ftp.debian.org/debian" - end + new_mirror ||= determine_mirror(new_url) new_mirrors ||= [new_mirror] unless new_mirror.nil? old_url = formula_spec.url old_tag = formula_spec.specs[:tag] @@ -422,6 +413,19 @@ def determine_formula_from_url(url) odie "Couldn't guess formula for sure; could be one of these:\n#{guesses.map(&:name).join(", ")}" end + def determine_mirror(url) + case url + when %r{.*ftp.gnu.org/gnu.*} + url.sub "ftp.gnu.org/gnu", "ftpmirror.gnu.org" + when %r{.*download.savannah.gnu.org/*} + url.sub "download.savannah.gnu.org", "download-mirror.savannah.gnu.org" + when %r{.*www.apache.org/dyn/closer.lua\?path=.*} + url.sub "www.apache.org/dyn/closer.lua?path=", "archive.apache.org/dist/" + when %r{.*mirrors.ocf.berkeley.edu/debian.*} + url.sub "mirrors.ocf.berkeley.edu/debian", "mirrorservice.org/sites/ftp.debian.org/debian" + end + end + def fetch_resource(formula, new_version, url, **specs) resource = Resource.new resource.url(url, specs)
false
Other
Homebrew
brew
efbfb90c42b6c106ab71c7a5340e05b81e7a133b.json
Use cask with name for basic info command test Also add non-dummy URL in the test fixture, to match the name, version, etc.
Library/Homebrew/test/cask/cmd/home_spec.rb
@@ -16,7 +16,7 @@ it "works for multiple Casks" do expect(described_class).to receive(:open_url).with("https://brew.sh/") - expect(described_class).to receive(:open_url).with("https://brew.sh/") + expect(described_class).to receive(:open_url).with("https://transmissionbt.com/") described_class.run("local-caffeine", "local-transmission") end
true
Other
Homebrew
brew
efbfb90c42b6c106ab71c7a5340e05b81e7a133b.json
Use cask with name for basic info command test Also add non-dummy URL in the test fixture, to match the name, version, etc.
Library/Homebrew/test/cask/cmd/info_spec.rb
@@ -10,16 +10,16 @@ it "displays some nice info about the specified Cask" do expect { - described_class.run("local-caffeine") + described_class.run("local-transmission") }.to output(<<~EOS).to_stdout - local-caffeine: 1.2.3 - https://brew.sh/ + local-transmission: 2.61 + https://transmissionbt.com/ Not installed - From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/local-caffeine.rb + From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/local-transmission.rb ==> Name - None + Transmission ==> Artifacts - Caffeine.app (App) + Transmission.app (App) EOS end @@ -51,7 +51,7 @@ Caffeine.app (App) local-transmission: 2.61 - https://brew.sh/ + https://transmissionbt.com/ Not installed From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/local-transmission.rb ==> Name
true
Other
Homebrew
brew
efbfb90c42b6c106ab71c7a5340e05b81e7a133b.json
Use cask with name for basic info command test Also add non-dummy URL in the test fixture, to match the name, version, etc.
Library/Homebrew/test/cask/cmd/list_spec.rb
@@ -90,7 +90,7 @@ let(:casks) { ["local-caffeine", "local-transmission"] } let(:expected_output) { <<~EOS - [{"token":"local-caffeine","name":[],"desc":null,"homepage":"https://brew.sh/","url":"file:///usr/local/Homebrew/Library/Homebrew/test/support/fixtures/cask/caffeine.zip","appcast":null,"version":"1.2.3","sha256":"67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94","artifacts":[["Caffeine.app"]],"caveats":null,"depends_on":{},"conflicts_with":null,"container":null,"auto_updates":null},{"token":"local-transmission","name":["Transmission"],"desc":null,"homepage":"https://brew.sh/","url":"file:///usr/local/Homebrew/Library/Homebrew/test/support/fixtures/cask/transmission-2.61.dmg","appcast":null,"version":"2.61","sha256":"e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68","artifacts":[["Transmission.app"]],"caveats":null,"depends_on":{},"conflicts_with":null,"container":null,"auto_updates":null}] + [{"token":"local-caffeine","name":[],"desc":null,"homepage":"https://brew.sh/","url":"file:///usr/local/Homebrew/Library/Homebrew/test/support/fixtures/cask/caffeine.zip","appcast":null,"version":"1.2.3","sha256":"67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94","artifacts":[["Caffeine.app"]],"caveats":null,"depends_on":{},"conflicts_with":null,"container":null,"auto_updates":null},{"token":"local-transmission","name":["Transmission"],"desc":null,"homepage":"https://transmissionbt.com/","url":"file:///usr/local/Homebrew/Library/Homebrew/test/support/fixtures/cask/transmission-2.61.dmg","appcast":null,"version":"2.61","sha256":"e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68","artifacts":[["Transmission.app"]],"caveats":null,"depends_on":{},"conflicts_with":null,"container":null,"auto_updates":null}] EOS }
true
Other
Homebrew
brew
efbfb90c42b6c106ab71c7a5340e05b81e7a133b.json
Use cask with name for basic info command test Also add non-dummy URL in the test fixture, to match the name, version, etc.
Library/Homebrew/test/support/fixtures/cask/Casks/local-transmission.rb
@@ -4,7 +4,7 @@ url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg" name "Transmission" - homepage "https://brew.sh/" + homepage "https://transmissionbt.com/" app "Transmission.app" end
true
Other
Homebrew
brew
ed23eb1fab44268a2ace3d5bafd2c45b38a6ce60.json
update repology for changes to GitHub module
Library/Homebrew/test/dev-cmd/bump_spec.rb
@@ -2,6 +2,19 @@ require "cmd/shared_examples/args_parse" -describe "Homebrew.bump_args" do - it_behaves_like "parseable arguments" +describe "brew bump" do + describe "Homebrew.bump_args" do + it_behaves_like "parseable arguments" + end + + describe "formula", :integration_test do + it "returns data for valid specified formula" do + install_test_formula "testball" + + expect { brew "bump", "--formula=testball" } + .to output.to_stdout + .and not_to_output.to_stderr + .and be_a_success + end + end end
true
Other
Homebrew
brew
ed23eb1fab44268a2ace3d5bafd2c45b38a6ce60.json
update repology for changes to GitHub module
Library/Homebrew/test/utils/repology_spec.rb
@@ -3,15 +3,10 @@ require "utils/repology" describe Repology do - describe "formula_data", :integration_test do + describe "formula_data" do it "returns nil for invalid Homebrew Formula" do expect(described_class.formula_data("invalidName")).to be_nil end - - it "validates Homebrew Formula by name" do - install_test_formula "testball" - expect(described_class.formula_data("testball")).not_to be_nil - end end describe "query_api" do @@ -49,25 +44,4 @@ expect(response).to be_a(Hash) end end - - describe "format_package", :integration_test do - it "returns nil if package is not a valid formula" do - invalid_formula_response = described_class.format_package("invalidName", "5.5.5") - - expect(invalid_formula_response).to be_nil - end - - it "returns hash with data for valid formula" do - install_test_formula "testball" - formatted_data = described_class.format_package("testball", "0.1") - - expect(formatted_data).not_to be_nil - expect(formatted_data).to be_a(Hash) - expect(formatted_data[:repology_latest_version]).not_to be_nil - expect(formatted_data[:current_formula_version]).not_to be_nil - expect(formatted_data[:current_formula_version]).to eq("0.1") - expect(formatted_data).to include(:livecheck_latest_version) - expect(formatted_data).to include(:open_pull_requests) - end - end end
true
Other
Homebrew
brew
ed23eb1fab44268a2ace3d5bafd2c45b38a6ce60.json
update repology for changes to GitHub module
Library/Homebrew/utils/repology.rb
@@ -63,7 +63,11 @@ def validate_and_format_packages(outdated_repology_packages, limit) next if repology_homebrew_repo.blank? - latest_version = repositories.find { |repo| repo["status"] == "newest" }["version"] + latest_version = repositories.find { |repo| repo["status"] == "newest" } + + next if latest_version.blank? + + latest_version = latest_version["version"] srcname = repology_homebrew_repo["srcname"] package_details = format_package(srcname, latest_version) packages[srcname] = package_details unless package_details.nil? @@ -79,15 +83,18 @@ def format_package(package_name, latest_version) return if formula.blank? + formula_name = formula.to_s tap_full_name = formula.tap&.full_name current_version = formula.version.to_s livecheck_response = LivecheckFormula.init(package_name) - pull_requests = GitHub.check_for_duplicate_pull_requests(formula, tap_full_name, latest_version) + pull_requests = GitHub.fetch_pull_requests(formula_name, tap_full_name, state: "open") if pull_requests.try(:any?) - pull_requests = pull_requests.map { |pr| "#{pr[:title]} (#{Formatter.url(pr[:url])})" }.join(", ") + pull_requests = pull_requests.map { |pr| "#{pr["title"]} (#{Formatter.url(pr["url"])})" }.join(", ") end + pull_requests = "None" if pull_requests.empty? + { repology_latest_version: latest_version, current_formula_version: current_version.to_s,
true
Other
Homebrew
brew
05d03a3909b4ae6771d016409fdbe17f4eae4c80.json
remove duplicate methods
Library/Homebrew/utils/github.rb
@@ -346,27 +346,6 @@ def print_pull_requests_matching(query) prs.each { |i| puts "#{i["title"]} (#{i["html_url"]})" } end - def fetch_pull_requests(query, tap_full_name, state: nil) - issues_for_formula(query, tap_full_name: tap_full_name, state: state).select do |pr| - pr["html_url"].include?("/pull/") && - /(^|\s)#{Regexp.quote(query)}(:|\s|$)/i =~ pr["title"] - end - rescue GitHub::RateLimitExceededError => e - opoo e.message - [] - end - - def check_for_duplicate_pull_requests(formula, tap_full_name, version) - # check for open requests - pull_requests = fetch_pull_requests(formula.name, tap_full_name, state: "open") - - # if we haven't already found open requests, try for an exact match across all requests - pull_requests = fetch_pull_requests("#{formula.name} #{version}", tap_full_name) if pull_requests.blank? - return if pull_requests.blank? - - pull_requests.map { |pr| { title: pr["title"], url: pr["html_url"] } } - end - def create_fork(repo) url = "#{API_URL}/repos/#{repo}/forks" data = {}
false
Other
Homebrew
brew
0bf7773a0baef2c925b88445f84867e1ef3bc382.json
audit: add existing prerelease formulae to allowlist
Library/Homebrew/dev-cmd/audit.rb
@@ -684,8 +684,13 @@ def get_repo_data(regex) }.freeze GITHUB_PRERELEASE_ALLOWLIST = { + "cbmc" => "5.12.6", + "elm-format" => "0.8.3", "gitless" => "0.8.8", + "infrakit" => "0.5", + "riff" => "0.5.0", "telegram-cli" => "1.3.1", + "volta" => "0.8.6", }.freeze # version_prefix = stable_version_string.sub(/\d+$/, "")
false
Other
Homebrew
brew
f3283b60ccf1d18676bae7f90de7ab439d78ad09.json
utils/ruby.sh: test_ruby(): keep temporary variables local
Library/Homebrew/utils/ruby.sh
@@ -11,7 +11,9 @@ test_ruby () { setup-ruby-path() { local vendor_dir + local vendor_ruby_root local vendor_ruby_path + local vendor_ruby_terminfo local vendor_ruby_latest_version local vendor_ruby_current_version local usable_ruby
false
Other
Homebrew
brew
ecbe2213e4ee19bb1b2ce434a7f9f0a2e56fa4dc.json
brew.sh: handle systems with no 'locale' such as Alpine Linux Closes Linuxbrew/docker#83
Library/Homebrew/brew.sh
@@ -6,7 +6,10 @@ case "$HOMEBREW_SYSTEM" in esac # Force UTF-8 to avoid encoding issues for users with broken locale settings. -if [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] +if ! which locale &>/dev/null +then + export LC_ALL=C +elif [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] then if [[ -n "$HOMEBREW_MACOS" ]] then
false
Other
Homebrew
brew
1c10f51f9855076b541001b4b033800977d31a7b.json
audit: check GitHub tags for prerelease status
Library/Homebrew/dev-cmd/audit.rb
@@ -781,7 +781,7 @@ def audit_specs return if stable_url_minor_version.even? problem "#{stable.version} is a development release" - when %r{^https://github.com/([\w-]+)/([\w-]+)/} + when %r{^https://github.com/([\w-]+)/([\w-]+)} owner = Regexp.last_match(1) repo = Regexp.last_match(2) tag = url.match(%r{^https://github\.com/[\w-]+/[\w-]+/archive/([^/]+)\.(tar\.gz|zip)$}) @@ -790,6 +790,7 @@ def audit_specs tag ||= url.match(%r{^https://github\.com/[\w-]+/[\w-]+/releases/download/([^/]+)/}) .to_a .second + tag ||= formula.stable.specs[:tag] begin if @online && (release = GitHub.open_api("#{GitHub::API_URL}/repos/#{owner}/#{repo}/releases/tags/#{tag}"))
false
Other
Homebrew
brew
8142bf2797e7411584e219255d0f849b3e9f0a90.json
rubocop/urls: add go@1.14 to binary URLs allowlist
Library/Homebrew/rubocops/urls.rb
@@ -35,6 +35,7 @@ class Urls < FormulaCop go@1.11 go@1.12 go@1.13 + go@1.14 haskell-stack ldc mlton
false
Other
Homebrew
brew
ac6295491c771c0da2856524b8e7bb39f1f7da72.json
cmd/cleanup.rb: fix input handling
Library/Homebrew/cmd/cleanup.rb
@@ -33,6 +33,10 @@ def cleanup_args def cleanup args = cleanup_args.parse + if args.prune.present? && !Integer(args.prune, exception: false) && args.prune != "all" + raise UsageError, "--prune= expects an integer or 'all'." + end + cleanup = Cleanup.new(*args.named, dry_run: args.dry_run?, scrub: args.s?, days: args.prune&.to_i) if args.prune_prefix? cleanup.prune_prefix_symlinks_and_directories
false
Other
Homebrew
brew
133155397c81a96612549d63b252821ba6c44ded.json
tests.yml: use proper matrix syntax Co-authored-by: Bo Anderson <mail@boanderson.me>
.github/workflows/tests.yml
@@ -9,7 +9,7 @@ env: jobs: tests: if: github.repository == 'Homebrew/brew' - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.config.os }} strategy: matrix: config: @@ -96,14 +96,14 @@ jobs: - name: Run brew readall on all taps run: brew readall --aliases - - name: Run brew style on ${{ matrix.core-tap }} + - name: Run brew style on ${{ matrix.config.core-tap }} run: brew style --display-cop-names homebrew/core - name: Run brew style on official taps run: brew style --display-cop-names homebrew/bundle homebrew/services homebrew/test-bot - name: Run brew cask style on all taps - if: matrix.os == 'macOS-latest' + if: matrix.config.os == 'macOS-latest' run: | brew tap homebrew/cask brew tap homebrew/cask-drivers @@ -121,13 +121,13 @@ jobs: vale docs/ - name: Lint Dockerfile - if: matrix.os == 'ubuntu-latest' + if: matrix.config.os == 'ubuntu-latest' run: | brew install hadolint hadolint Dockerfile - name: Build Docker image - if: matrix.os == 'ubuntu-latest' + if: matrix.config.os == 'ubuntu-latest' run: docker build -t brew --build-arg=version=16.04 . - name: Run brew test-bot --only-formulae --test-default-formula @@ -139,7 +139,7 @@ jobs: fi - name: Deploy the Docker image to GitHub and Docker Hub - if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master' + if: matrix.config.os == 'ubuntu-latest' && github.ref == 'refs/heads/master' run: | docker login docker.pkg.github.com -u BrewTestBot -p ${{secrets.GITHUB_TOKEN}} docker tag brew "docker.pkg.github.com/homebrew/brew/ubuntu16.04:master"
false
Other
Homebrew
brew
e9b6a6df4bd6d04ecef771102c7ab257b0ac3079.json
test/pkg_version_spec: add version token examples
Library/Homebrew/test/pkg_version_spec.rb
@@ -85,4 +85,46 @@ expect(p1.hash).not_to eq(p4.hash) end end + + describe "#version" do + it "returns package version" do + expect(described_class.parse("1.2.3_4").version).to be == Version.create("1.2.3") + end + end + + describe "#revision" do + it "returns package revision" do + expect(described_class.parse("1.2.3_4").revision).to be == 4 + end + end + + describe "#major" do + it "returns major version token" do + expect(described_class.parse("1.2.3_4").major).to be == Version::Token.create("1") + end + end + + describe "#minor" do + it "returns minor version token" do + expect(described_class.parse("1.2.3_4").minor).to be == Version::Token.create("2") + end + end + + describe "#patch" do + it "returns patch version token" do + expect(described_class.parse("1.2.3_4").patch).to be == Version::Token.create("3") + end + end + + describe "#major_minor" do + it "returns major.minor version" do + expect(described_class.parse("1.2.3_4").major_minor).to be == Version.create("1.2") + end + end + + describe "#major_minor_patch" do + it "returns major.minor.patch version" do + expect(described_class.parse("1.2.3_4").major_minor_patch).to be == Version.create("1.2.3") + end + end end
false
Other
Homebrew
brew
e27f7b0ed101608fbcb5e36e3cef77f3ffbda40d.json
audit: use version token helper methods
Library/Homebrew/dev-cmd/audit.rb
@@ -261,9 +261,8 @@ def audit_file !(versioned_formulae = formula.versioned_formulae).empty? versioned_aliases = formula.aliases.grep(/.@\d/) _, last_alias_version = versioned_formulae.map(&:name).last.split("@") - major, minor, = formula.version.to_s.split(".") - alias_name_major = "#{formula.name}@#{major}" - alias_name_major_minor = "#{alias_name_major}.#{minor}" + alias_name_major = "#{formula.name}@#{formula.version.major}" + alias_name_major_minor = "#{alias_name_major}.#{formula.version.minor}" alias_name = if last_alias_version.split(".").length == 1 alias_name_major else @@ -488,11 +487,7 @@ def audit_postgresql return unless formula.name == "postgresql" return unless @core_tap - major_version = formula.version - .to_s - .split(".") - .first - .to_i + major_version = formula.version.major.to_i previous_major_version = major_version - 1 previous_formula_name = "postgresql@#{previous_major_version}" begin @@ -689,7 +684,7 @@ def get_repo_data(regex) }.freeze # version_prefix = stable_version_string.sub(/\d+$/, "") - # version_prefix = stable_version_string.split(".")[0..1].join(".") + # version_prefix = stable.version.major_minor def audit_specs problem "Head-only (no stable download)" if head_only?(formula) @@ -753,11 +748,9 @@ def audit_specs stable_version_string = stable.version.to_s stable_url_version = Version.parse(stable.url) - _, stable_url_minor_version, = stable_url_version.to_s - .split(".", 3) - .map(&:to_i) + stable_url_minor_version = stable_url_version.minor.to_i - formula_suffix = stable_version_string.split(".").last.to_i + formula_suffix = stable.version.patch.to_i throttled_rate = THROTTLED_FORMULAE[formula.name] if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero? problem "should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}" @@ -771,7 +764,7 @@ def audit_specs problem "Stable version URLs should not contain #{matched}" when %r{download\.gnome\.org/sources}, %r{ftp\.gnome\.org/pub/GNOME/sources}i - version_prefix = stable_version_string.split(".")[0..1].join(".") + version_prefix = stable.version.major_minor return if GNOME_DEVEL_ALLOWLIST[formula.name] == version_prefix return if stable_url_version < Version.create("1.0") return if stable_url_minor_version.even?
false
Other
Homebrew
brew
f2112d67618fdff48dc6bba410c08e337f81774b.json
version: add helper methods to Token class
Library/Homebrew/version.rb
@@ -46,6 +46,18 @@ def inspect "#<#{self.class.name} #{value.inspect}>" end + def hash + value.hash + end + + def to_f + value.to_f + end + + def to_i + value.to_i + end + def to_s value.to_s end @@ -75,6 +87,10 @@ def <=>(other) end end + def null? + true + end + def inspect "#<#{self.class.name}>" end
false
Other
Homebrew
brew
919e94bb9273a48ade57a2be184e9c3ee5e8dc07.json
test/version_spec: add major/minor/patch examples
Library/Homebrew/test/version_spec.rb
@@ -276,6 +276,76 @@ expect(v2.to_str).to eq("HEAD-ffffff") end + describe "#major" do + it "returns major version token" do + expect(described_class.create("1").major).to be == Version::Token.create("1") + expect(described_class.create("1.2").major).to be == Version::Token.create("1") + expect(described_class.create("1.2.3").major).to be == Version::Token.create("1") + expect(described_class.create("1.2.3alpha").major).to be == Version::Token.create("1") + expect(described_class.create("1.2.3alpha4").major).to be == Version::Token.create("1") + expect(described_class.create("1.2.3beta4").major).to be == Version::Token.create("1") + expect(described_class.create("1.2.3pre4").major).to be == Version::Token.create("1") + expect(described_class.create("1.2.3rc4").major).to be == Version::Token.create("1") + expect(described_class.create("1.2.3-p4").major).to be == Version::Token.create("1") + end + end + + describe "#minor" do + it "returns minor version token" do + expect(described_class.create("1").minor).to be nil + expect(described_class.create("1.2").minor).to be == Version::Token.create("2") + expect(described_class.create("1.2.3").minor).to be == Version::Token.create("2") + expect(described_class.create("1.2.3alpha").minor).to be == Version::Token.create("2") + expect(described_class.create("1.2.3alpha4").minor).to be == Version::Token.create("2") + expect(described_class.create("1.2.3beta4").minor).to be == Version::Token.create("2") + expect(described_class.create("1.2.3pre4").minor).to be == Version::Token.create("2") + expect(described_class.create("1.2.3rc4").minor).to be == Version::Token.create("2") + expect(described_class.create("1.2.3-p4").minor).to be == Version::Token.create("2") + end + end + + describe "#patch" do + it "returns patch version token" do + expect(described_class.create("1").patch).to be nil + expect(described_class.create("1.2").patch).to be nil + expect(described_class.create("1.2.3").patch).to be == Version::Token.create("3") + expect(described_class.create("1.2.3alpha").patch).to be == Version::Token.create("3") + expect(described_class.create("1.2.3alpha4").patch).to be == Version::Token.create("3") + expect(described_class.create("1.2.3beta4").patch).to be == Version::Token.create("3") + expect(described_class.create("1.2.3pre4").patch).to be == Version::Token.create("3") + expect(described_class.create("1.2.3rc4").patch).to be == Version::Token.create("3") + expect(described_class.create("1.2.3-p4").patch).to be == Version::Token.create("3") + end + end + + describe "#major_minor" do + it "returns major.minor version" do + expect(described_class.create("1").major_minor).to be == described_class.create("1") + expect(described_class.create("1.2").major_minor).to be == described_class.create("1.2") + expect(described_class.create("1.2.3").major_minor).to be == described_class.create("1.2") + expect(described_class.create("1.2.3alpha").major_minor).to be == described_class.create("1.2") + expect(described_class.create("1.2.3alpha4").major_minor).to be == described_class.create("1.2") + expect(described_class.create("1.2.3beta4").major_minor).to be == described_class.create("1.2") + expect(described_class.create("1.2.3pre4").major_minor).to be == described_class.create("1.2") + expect(described_class.create("1.2.3rc4").major_minor).to be == described_class.create("1.2") + expect(described_class.create("1.2.3-p4").major_minor).to be == described_class.create("1.2") + end + end + + describe "#major_minor_patch" do + it "returns major.minor.patch version" do + expect(described_class.create("1").major_minor_patch).to be == described_class.create("1") + expect(described_class.create("1.2").major_minor_patch).to be == described_class.create("1.2") + expect(described_class.create("1.2.3").major_minor_patch).to be == described_class.create("1.2.3") + expect(described_class.create("1.2.3alpha").major_minor_patch).to be == described_class.create("1.2.3") + expect(described_class.create("1.2.3alpha4").major_minor_patch).to be == described_class.create("1.2.3") + expect(described_class.create("1.2.3beta4").major_minor_patch).to be == described_class.create("1.2.3") + expect(described_class.create("1.2.3pre4").major_minor_patch).to be == described_class.create("1.2.3") + expect(described_class.create("1.2.3rc4").major_minor_patch).to be == described_class.create("1.2.3") + expect(described_class.create("1.2.3-p4").major_minor_patch).to be == described_class.create("1.2.3") + end + end + describe "::parse" do it "returns a NULL version when the URL cannot be parsed" do expect(described_class.parse("https://brew.sh/blah.tar")).to be_null
false
Other
Homebrew
brew
03c83749c5fdf47436f5a1d2c94a20e6b9ae9540.json
reinstall: fix error when building from source Fixes Homebrew/homebrew-core#59437.
Library/Homebrew/reinstall.rb
@@ -23,8 +23,11 @@ def reinstall_formula(f, build_from_source: false, args:) options |= f.build.used_options options &= f.options + build_from_source_formulae = args.build_from_source_formulae + build_from_source_formulae << f.full_name if build_from_source + fi = FormulaInstaller.new(f, force_bottle: args.force_bottle?, - build_from_source_formulae: args.build_from_source_formulae, + build_from_source_formulae: build_from_source_formulae, debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?) fi.options = options fi.force = args.force? @@ -33,7 +36,6 @@ def reinstall_formula(f, build_from_source: false, args:) fi.interactive = args.interactive? fi.git = args.git? fi.link_keg ||= keg_was_linked if keg_had_linked_opt - fi.build_from_source = true if build_from_source if tab fi.build_bottle ||= tab.built_bottle? fi.installed_as_dependency = tab.installed_as_dependency
false
Other
Homebrew
brew
c7ce11963333802582b23ab946096df5e78429f0.json
sorbet: solve typecheck errors. 23 => 15 errors
Library/Homebrew/sorbet/rbi/cli.rbi
@@ -17,5 +17,21 @@ module Homebrew::CLI def named_args; end def force_bottle?; end + + def debug?; end + + def quiet?; end + + def verbose?; end + end + + + class Parser + module Compat + include Kernel + module DeprecatedArgs + include Kernel + end + end end end
true
Other
Homebrew
brew
c7ce11963333802582b23ab946096df5e78429f0.json
sorbet: solve typecheck errors. 23 => 15 errors
Library/Homebrew/sorbet/rbi/homebrew.rbi
@@ -20,6 +20,16 @@ module Dependable def tags; end end +module DependenciesHelpers + include Kernel + + module Compat + include Kernel + + def args_includes_ignores(args); end + end +end + class Formula module Compat include Kernel
true
Other
Homebrew
brew
c7ce11963333802582b23ab946096df5e78429f0.json
sorbet: solve typecheck errors. 23 => 15 errors
Library/Homebrew/sorbet/rbi/utils/spdx.rbi
@@ -0,0 +1,11 @@ +# typed: strict + +module SPDX + include Kernel + + def spdx_data; end + + def download_latest_license_data!(to: JSON_PATH); end + + def curl_download(*args, to: nil, partial: true, **options); end +end
true
Other
Homebrew
brew
183d76d59ed3938cea105fde7351c85e4994617f.json
Add tests for livecheck_formula utils
Library/Homebrew/test/utils/livecheck_formula_spec.rb
@@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require "utils/livecheck_formula" + +describe LivecheckFormula do + describe "init", :integration_test do + it "runs livecheck command for Formula" do + install_test_formula "testball" + + formatted_response = described_class.init("testball") + + expect(formatted_response).not_to be_nil + expect(formatted_response).to be_a(Hash) + expect(formatted_response.size).not_to eq(0) + + # expect(formatted_response[:name]).to eq("testball") + # expect(formatted_response[:formula_version]).not_to be_nil + # expect(formatted_response[:livecheck_version]).not_to be_nil + end + end + + describe "parse_livecheck_response" do + it "returns a hash of Formula version data" do + example_raw_command_response = "aacgain : 7834 ==> 1.8" + formatted_response = described_class.parse_livecheck_response(example_raw_command_response) + + expect(formatted_response).not_to be_nil + expect(formatted_response).to be_a(Hash) + + expect(formatted_response).to include(:name) + expect(formatted_response).to include(:formula_version) + expect(formatted_response).to include(:livecheck_version) + + expect(formatted_response[:name]).to eq("aacgain") + expect(formatted_response[:formula_version]).to eq("7834") + expect(formatted_response[:livecheck_version]).to eq("1.8") + end + end +end
false
Other
Homebrew
brew
7409bae0b8e37f4f4b39f0ae0588ed44a1c9fc97.json
sorbet/files.yaml: add new files, 18 => 23 errors. Add new files to the list of all files in sorbet/files.yaml. following 8 files are added to false: - ./cmd/--caskroom.rb - ./rubocops/cask/mixin/on_desc_stanza.rb - ./rubocops/shared/desc_helper.rb - ./rubocops/shared/helper_functions.rb - ./test/cmd/--caskroom_spec.rb - ./test/dependencies_helpers_spec.rb - ./test/rubocops/cask/desc_spec.rb - ./test/utils/spdx_spec.rb following 6 files are added to true: - ./compat/cli/parser.rb - ./compat/dependencies_helpers.rb - ./context.rb - ./dependencies_helpers.rb - ./rubocops/cask/desc.rb - ./utils/spdx.rb
Library/Homebrew/sorbet/files.yaml
@@ -82,6 +82,7 @@ false: - ./cleanup.rb - ./cli/parser.rb - ./cmd/--cache.rb + - ./cmd/--caskroom.rb - ./cmd/--cellar.rb - ./cmd/--env.rb - ./cmd/--prefix.rb @@ -489,9 +490,12 @@ false: - ./rubocops/cask/homepage_matches_url.rb - ./rubocops/cask/homepage_url_trailing_slash.rb - ./rubocops/cask/mixin/cask_help.rb + - ./rubocops/cask/mixin/on_desc_stanza.rb - ./rubocops/cask/mixin/on_homepage_stanza.rb - ./rubocops/cask/no_dsl_version.rb - ./rubocops/cask/stanza_order.rb + - ./rubocops/shared/desc_helper.rb + - ./rubocops/shared/helper_functions.rb - ./searchable.rb - ./test/PATH_spec.rb - ./test/bash_spec.rb @@ -512,6 +516,7 @@ false: - ./test/checksum_spec.rb - ./test/cleaner_spec.rb - ./test/cmd/--cache_spec.rb + - ./test/cmd/--caskroom_spec.rb - ./test/cmd/--cellar_spec.rb - ./test/cmd/--env_spec.rb - ./test/cmd/--prefix_spec.rb @@ -555,6 +560,7 @@ false: - ./test/compiler_failure_spec.rb - ./test/cxxstdlib_spec.rb - ./test/dependable_spec.rb + - ./test/dependencies_helpers_spec.rb - ./test/descriptions_spec.rb - ./test/dev-cmd/bottle_spec.rb - ./test/dev-cmd/bump-formula-pr_spec.rb @@ -617,6 +623,7 @@ false: - ./test/requirements/osxfuse_requirement_spec.rb - ./test/requirements_spec.rb - ./test/rubocop_spec.rb + - ./test/rubocops/cask/desc_spec.rb - ./test/rubocops/cask/homepage_matches_url_spec.rb - ./test/rubocops/cask/homepage_url_trailing_slash_spec.rb - ./test/rubocops/cask/no_dsl_version_spec.rb @@ -818,6 +825,7 @@ false: - ./test/utils/github_spec.rb - ./test/utils/popen_spec.rb - ./test/utils/shell_spec.rb + - ./test/utils/spdx_spec.rb - ./test/utils/svn_spec.rb - ./test/utils/tty_spec.rb - ./test/version_spec.rb @@ -837,13 +845,17 @@ true: - ./checksum.rb - ./cleaner.rb - ./cli/args.rb + - ./compat/cli/parser.rb + - ./compat/dependencies_helpers.rb - ./compat/extend/nil.rb - ./compat/extend/string.rb - ./compat/formula.rb - ./compat/os/mac.rb - ./compilers.rb - ./config.rb + - ./context.rb - ./dependable.rb + - ./dependencies_helpers.rb - ./dependency_collector.rb - ./description_cache_store.rb - ./descriptions.rb @@ -883,6 +895,7 @@ true: - ./rubocops/cask/ast/cask_header.rb - ./rubocops/cask/ast/stanza.rb - ./rubocops/cask/constants/stanza.rb + - ./rubocops/cask/desc.rb - ./rubocops/cask/extend/string.rb - ./rubocops/deprecate.rb - ./tap_constants.rb @@ -894,6 +907,7 @@ true: - ./utils/notability.rb - ./utils/shebang.rb - ./utils/shell.rb + - ./utils/spdx.rb - ./utils/svn.rb - ./utils/tty.rb - ./utils/user.rb
false
Other
Homebrew
brew
f345f554c898748967a0b7768387d88eaa03176d.json
update-license-data: fix latest_tag error Add latest_tag method to utils/spdx
Library/Homebrew/dev-cmd/update-license-data.rb
@@ -35,6 +35,6 @@ def update_license_data ohai "git add" safe_system "git", "add", SPDX::JSON_PATH ohai "git commit" - system "git", "commit", "--message", "data/spdx.json: update to #{latest_tag}" + system "git", "commit", "--message", "data/spdx.json: update to #{SPDX.latest_tag}" end end
true
Other
Homebrew
brew
f345f554c898748967a0b7768387d88eaa03176d.json
update-license-data: fix latest_tag error Add latest_tag method to utils/spdx
Library/Homebrew/utils/spdx.rb
@@ -12,8 +12,11 @@ def spdx_data @spdx_data ||= JSON.parse(JSON_PATH.read) end + def latest_tag + @latest_tag ||= GitHub.open_api(API_URL)["tag_name"] + end + def download_latest_license_data!(to: JSON_PATH) - latest_tag = GitHub.open_api(API_URL)["tag_name"] data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json" curl_download(data_url, to: to, partial: false) end
true
Other
Homebrew
brew
549cd5b47121e2b7b065c119eec80446b9658439.json
Ensure new casks have a description.
Library/Homebrew/cask/audit.rb
@@ -13,7 +13,7 @@ class Audit attr_reader :cask, :commit_range, :download - attr_predicate :appcast? + attr_predicate :appcast?, :new_cask?, :strict?, :online? def initialize(cask, appcast: false, download: false, quarantine: nil, token_conflicts: false, online: false, strict: false, @@ -34,6 +34,7 @@ def run! check_required_stanzas check_version check_sha256 + check_desc check_url check_generic_artifacts check_token_valid @@ -279,6 +280,14 @@ def check_hosting_with_appcast end end + def check_desc + return unless new_cask? + + return if cask.desc.present? + + add_warning "Cask should have a description. Please add a `desc` stanza." + end + def check_url return unless cask.url @@ -339,7 +348,7 @@ def check_token_conflicts end def check_token_valid - return unless @strict + return unless strict? add_warning "cask token is not lowercase" if cask.token.downcase! @@ -365,7 +374,7 @@ def check_token_valid end def check_token_bad_words - return unless @strict + return unless strict? token = cask.token @@ -467,8 +476,8 @@ def check_bitbucket_repository end def get_repo_data(regex) - return unless @online - return unless @new_cask + return unless online? + return unless new_cask? _, user, repo = *regex.match(cask.url.to_s) _, user, repo = *regex.match(cask.homepage) unless user
true
Other
Homebrew
brew
549cd5b47121e2b7b065c119eec80446b9658439.json
Ensure new casks have a description.
Library/Homebrew/test/cask/audit_spec.rb
@@ -33,12 +33,14 @@ def include_msg?(messages, msg) let(:download) { false } let(:token_conflicts) { false } let(:strict) { false } + let(:new_cask) { false } let(:fake_system_command) { class_double(SystemCommand) } let(:audit) { described_class.new(cask, download: download, token_conflicts: token_conflicts, command: fake_system_command, - strict: strict) + strict: strict, + new_cask: new_cask) } describe "#result" do @@ -790,5 +792,58 @@ def tmp_cask(name, text) expect(subject).to fail_with(/exception while auditing/) end end + + describe "without description" do + let(:cask_token) { "without-description" } + let(:cask) do + tmp_cask cask_token.to_s, <<~RUBY + cask '#{cask_token}' do + version '1.0' + sha256 '8dd95daa037ac02455435446ec7bc737b34567afe9156af7d20b2a83805c1d8a' + url "https://brew.sh/" + name 'Audit' + homepage 'https://brew.sh/' + app 'Audit.app' + end + RUBY + end + + context "when `new_cask` is true" do + let(:new_cask) { true } + + it "warns" do + expect(subject).to warn_with(/should have a description/) + end + end + + context "when `new_cask` is true" do + let(:new_cask) { false } + + it "does not warn" do + expect(subject).not_to warn_with(/should have a description/) + end + end + end + + context "with description" do + let(:cask_token) { "with-description" } + let(:cask) do + tmp_cask cask_token.to_s, <<~RUBY + cask '#{cask_token}' do + version '1.0' + sha256 '8dd95daa037ac02455435446ec7bc737b34567afe9156af7d20b2a83805c1d8a' + url "https://brew.sh/" + name 'Audit' + desc 'Cask Auditor' + homepage 'https://brew.sh/' + app 'Audit.app' + end + RUBY + end + + it "does not warn" do + expect(subject).not_to warn_with(/should have a description/) + end + end end end
true
Other
Homebrew
brew
677714d801969aedc57ab01d9ad395ef3bbba11e.json
utils/pypi: add cdk8s to blocklist
Library/Homebrew/utils/pypi.rb
@@ -8,6 +8,7 @@ module PyPI AUTOMATIC_RESOURCE_UPDATE_BLOCKLIST = %w[ ansible ansible@2.8 + cdk8s cloudformation-cli diffoscope dxpy
false
Other
Homebrew
brew
6a98b235756c8b3803bd99af0be920990ad6030b.json
bundler: use 1.17.2 again. This was what is included with macOS system Ruby 2.6.3.
Library/Homebrew/Gemfile.lock
@@ -168,4 +168,4 @@ DEPENDENCIES tapioca BUNDLED WITH - 1.17.3 + 1.17.2
true
Other
Homebrew
brew
6a98b235756c8b3803bd99af0be920990ad6030b.json
bundler: use 1.17.2 again. This was what is included with macOS system Ruby 2.6.3.
Library/Homebrew/utils/gems.rb
@@ -8,7 +8,7 @@ module Homebrew # Keep in sync with the Gemfile.lock's BUNDLED WITH. - HOMEBREW_BUNDLER_VERSION = "1.17.3" + HOMEBREW_BUNDLER_VERSION = "1.17.2" module_function
true
Other
Homebrew
brew
8b55f8f9a44a6f7acc0bfda6ee1708566b1f461e.json
version: detect versions with final/full suffix
Library/Homebrew/test/version_spec.rb
@@ -671,6 +671,27 @@ .to be_detected_from("https://ftpmirror.gnu.org/libidn/libidn-1.29-win64.zip") end + specify "breseq version style" do + expect(described_class.create("0.35.1")) + .to be_detected_from( + "https://github.com/barricklab/breseq" \ + "/releases/download/v0.35.1/breseq-0.35.1.Source.tar.gz", + ) + end + + specify "wildfly version style" do + expect(described_class.create("20.0.1")) + .to be_detected_from("https://download.jboss.org/wildfly/20.0.1.Final/wildfly-20.0.1.Final.tar.gz") + end + + specify "trinity version style" do + expect(described_class.create("2.10.0")) + .to be_detected_from( + "https://github.com/trinityrnaseq/trinityrnaseq" \ + "/releases/download/v2.10.0/trinityrnaseq-v2.10.0.FULL.tar.gz", + ) + end + specify "with arch" do expect(described_class.create("4.0.18-1")) .to be_detected_from("https://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm")
true
Other
Homebrew
brew
8b55f8f9a44a6f7acc0bfda6ee1708566b1f461e.json
version: detect versions with final/full suffix
Library/Homebrew/version.rb
@@ -301,7 +301,7 @@ def self._parse(spec) # e.g. foobar-4.5.1-1 # e.g. unrtf_0.20.4-1 # e.g. ruby-1.9.1-p243 - m = /[-_]((?:\d+\.)*\d+\.\d+-(?:p|rc|RC)?\d+)(?:[-._](?:bin|dist|stable|src|sources))?$/.match(stem) + m = /[-_]((?:\d+\.)*\d+\.\d+-(?:p|rc|RC)?\d+)(?:[-._](?i:bin|dist|stable|src|sources?|final|full))?$/.match(stem) return m.captures.first unless m.nil? # URL with no extension @@ -359,7 +359,7 @@ def self._parse(spec) return m.captures.first unless m.nil? # e.g. foobar-4.5.0-bin - m = /-((?:\d+\.)+\d+[abc]?)[-._](?:bin|dist|stable|src|sources?)$/.match(stem) + m = /[-vV]((?:\d+\.)+\d+[abc]?)[-._](?i:bin|dist|stable|src|sources?|final|full)$/.match(stem) return m.captures.first unless m.nil? # dash version style
true
Other
Homebrew
brew
3b86e1f9c1931e5337a4d27a67f569f8679689bb.json
Implement RuboCop for cask `desc` stanza.
Library/.rubocop_cask.yml
@@ -1,5 +1,9 @@ inherit_from: ./Homebrew/.rubocop.yml +Cask/Desc: + Description: 'Ensure that the desc stanza conforms to various content and style checks.' + Enabled: true + Cask/HomepageMatchesUrl: Description: 'Ensure that the homepage and url match, otherwise add a comment. More info at https://github.com/Homebrew/homebrew-cask/blob/HEAD/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-a-comment' Enabled: true
true
Other
Homebrew
brew
3b86e1f9c1931e5337a4d27a67f569f8679689bb.json
Implement RuboCop for cask `desc` stanza.
Library/Homebrew/rubocops/cask/ast/cask_header.rb
@@ -29,7 +29,13 @@ def preferred_header_str end def cask_token - @cask_token ||= pair_node.val_node.children.first + @cask_token ||= begin + if dsl_version? + pair_node.val_node.children.first + else + method_node.first_argument.str_content + end + end end def hash_node
true
Other
Homebrew
brew
3b86e1f9c1931e5337a4d27a67f569f8679689bb.json
Implement RuboCop for cask `desc` stanza.
Library/Homebrew/rubocops/cask/desc.rb
@@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require "forwardable" +require "uri" +require "rubocops/cask/mixin/on_desc_stanza" +require "rubocops/shared/desc_helper" + +module RuboCop + module Cop + module Cask + # This cop audits `desc` in Casks. + # See the `DescHelper` module for details of the checks. + class Desc < Cop + include OnDescStanza + include DescHelper + + def on_desc_stanza(stanza) + name = cask_block.header.cask_token + desc_call = stanza.stanza_node + audit_desc(:cask, name, desc_call) + end + + def autocorrect(node) + name = cask_block.header.cask_token + autocorrect_desc(node, name) + end + end + end + end +end
true
Other
Homebrew
brew
3b86e1f9c1931e5337a4d27a67f569f8679689bb.json
Implement RuboCop for cask `desc` stanza.
Library/Homebrew/rubocops/cask/mixin/on_desc_stanza.rb
@@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Cask + # Common functionality for checking desc stanzas. + module OnDescStanza + extend Forwardable + include CaskHelp + + def on_cask(cask_block) + @cask_block = cask_block + + toplevel_stanzas.select(&:desc?).each do |stanza| + on_desc_stanza(stanza) + end + end + + private + + attr_reader :cask_block + + def_delegators :cask_block, + :toplevel_stanzas + end + end + end +end
true
Other
Homebrew
brew
3b86e1f9c1931e5337a4d27a67f569f8679689bb.json
Implement RuboCop for cask `desc` stanza.
Library/Homebrew/rubocops/rubocop-cask.rb
@@ -11,6 +11,7 @@ require "rubocops/cask/extend/node" require "rubocops/cask/mixin/cask_help" require "rubocops/cask/mixin/on_homepage_stanza" +require "rubocops/cask/desc" require "rubocops/cask/homepage_matches_url" require "rubocops/cask/homepage_url_trailing_slash" require "rubocops/cask/no_dsl_version"
true
Other
Homebrew
brew
3b86e1f9c1931e5337a4d27a67f569f8679689bb.json
Implement RuboCop for cask `desc` stanza.
Library/Homebrew/test/rubocops/cask/desc_spec.rb
@@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require "rubocops/rubocop-cask" +require "test/rubocops/cask/shared_examples/cask_cop" + +describe RuboCop::Cop::Cask::Desc do + include CaskCop + + subject(:cop) { described_class.new } + + context "with incorrect `desc` stanza" do + let(:source) { + <<~RUBY + cask "foo" do + desc "A bar program" + end + RUBY + } + let(:correct_source) { + <<~RUBY + cask "foo" do + desc "Bar program" + end + RUBY + } + let(:expected_offenses) do + [{ + message: "Description shouldn't start with an indefinite article, i.e. \"A\".", + severity: :convention, + line: 2, + column: 8, + source: "A", + }] + end + + include_examples "reports offenses" + + include_examples "autocorrects source" + end + + context "with correct `desc` stanza" do + let(:source) { + <<~RUBY + cask "foo" do + desc "Bar program" + end + RUBY + } + + include_examples "does not report any offenses" + end +end
true
Other
Homebrew
brew
3b86e1f9c1931e5337a4d27a67f569f8679689bb.json
Implement RuboCop for cask `desc` stanza.
Library/Homebrew/test/rubocops/cask/no_dsl_version_spec.rb
@@ -8,31 +8,27 @@ subject(:cop) { described_class.new } - context "with header method `cask`" do - let(:header_method) { "cask" } + context "with no dsl version" do + let(:source) { "cask 'foo' do; end" } - context "with no dsl version" do - let(:source) { "cask 'foo' do; end" } + include_examples "does not report any offenses" + end - include_examples "does not report any offenses" + context "with dsl version" do + let(:source) { "cask :v1 => 'foo' do; end" } + let(:correct_source) { "cask 'foo' do; end" } + let(:expected_offenses) do + [{ + message: "Use `cask 'foo'` instead of `cask :v1 => 'foo'`", + severity: :convention, + line: 1, + column: 0, + source: "cask :v1 => 'foo'", + }] end - context "with dsl version" do - let(:source) { "cask :v1 => 'foo' do; end" } - let(:correct_source) { "cask 'foo' do; end" } - let(:expected_offenses) do - [{ - message: "Use `cask 'foo'` instead of `cask :v1 => 'foo'`", - severity: :convention, - line: 1, - column: 0, - source: "cask :v1 => 'foo'", - }] - end - - include_examples "reports offenses" - - include_examples "autocorrects source" - end + include_examples "reports offenses" + + include_examples "autocorrects source" end end
true
Other
Homebrew
brew
ffed8fdbb3855fdae0dbef464cfcf68b26b84436.json
Add a `desc` stanza to the cask DSL
Library/Homebrew/cask/cask.rb
@@ -155,6 +155,7 @@ def to_h { "token" => token, "name" => name, + "desc" => desc, "homepage" => homepage, "url" => url, "appcast" => appcast,
true