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 | 7b0f27ca3929faeff3deb0fcbbecb314f805884e.json | style: Fix style errors | Library/Homebrew/dev-cmd/test.rb | @@ -1,4 +1,4 @@
-#: * test [--devel|--HEAD] [--debug] [--keep-tmp] [formula]:
+#: * `test` [`--devel`|`--HEAD`] [`--debug`] [`--keep-tmp`] <formula>:
#: Most formulae provide a test method. `brew test` <formula> runs this
#: test method. There is no standard output or return code, but it should
#: generally indicate to the user if something is wrong with the installed | true |
Other | Homebrew | brew | 7b0f27ca3929faeff3deb0fcbbecb314f805884e.json | style: Fix style errors | Library/Homebrew/help.rb | @@ -40,7 +40,7 @@ module Help
def help(cmd = nil, flags = {})
# Let OptionParser generate help text for commands which have a parser defined
begin
- Homebrew.send("#{cmd.gsub('-','_')}_args".to_sym)
+ Homebrew.send("#{cmd.tr("-", "_")}_args".to_sym)
return
rescue NoMethodError
nil | true |
Other | Homebrew | brew | 7b0f27ca3929faeff3deb0fcbbecb314f805884e.json | style: Fix style errors | docs/Manpage.md | @@ -832,13 +832,14 @@ Return a failing status code if changes are detected in the manpage outputs. Thi
It is now done automatically by `brew update`.
###`mirror` `formulae`:
-
+
Reuploads the stable URL for a formula to Bintray to use it as a mirror.
- * `prof` [ruby options]:
+ * `prof` [`ruby options`]:
Run Homebrew with the Ruby profiler.
For example:
+ brew prof readall
###pull `options` `formula`:
@@ -895,11 +896,11 @@ Output as a Markdown list.
For example:
###`tap-new` `user`/`repo`:
-
+
Generate the template files for a new tap.
- * test [--devel|--HEAD] [--debug] [--keep-tmp] [formula]:
+ * `test` [`--devel`|`--HEAD`] [`--debug`] [`--keep-tmp`] `formula`:
Most formulae provide a test method. `brew test` `formula` runs this
test method. There is no standard output or return code, but it should
generally indicate to the user if something is wrong with the installed | true |
Other | Homebrew | brew | 7b0f27ca3929faeff3deb0fcbbecb314f805884e.json | style: Fix style errors | manpages/brew.1 | @@ -863,8 +863,8 @@ It is now done automatically by \fBbrew update\fR\.
Reuploads the stable URL for a formula to Bintray to use it as a mirror\.
.
.TP
-\fBprof\fR [ruby options]
-Run Homebrew with the Ruby profiler\. For example:
+\fBprof\fR [\fIruby options\fR]
+Run Homebrew with the Ruby profiler\. For example: brew prof readall
.
.SS "pull \fIoptions\fR \fIformula\fR:"
Gets a patch from a GitHub commit or pull request and applies it to Homebrew\. Optionally, installs the formulae changed by the patch\.
@@ -943,7 +943,7 @@ Run a Ruby instance with Homebrew\'s libraries loaded\. For example:
Generate the template files for a new tap\.
.
.TP
-test [\-\-devel|\-\-HEAD] [\-\-debug] [\-\-keep\-tmp] [formula]
+\fBtest\fR [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-debug\fR] [\fB\-\-keep\-tmp\fR] \fIformula\fR
Most formulae provide a test method\. \fBbrew test\fR \fIformula\fR runs this test method\. There is no standard output or return code, but it should generally indicate to the user if something is wrong with the installed formula\.
.
.IP | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/cli_parser.rb | @@ -11,6 +11,15 @@ def self.parse(args = ARGV, &block)
new(&block).parse(args)
end
+ def self.global_options
+ {
+ quiet: [["-q", "--quiet"], :quiet, "Suppress any warnings."],
+ verbose: [["-v", "--verbose"], :verbose, "Make some output more verbose."],
+ debug: [["-d", "--debug"], :debug, "Display any debugging information."],
+ force: [["-f", "--force"], :force, "Override warnings and enable potentially unsafe operations."],
+ }
+ end
+
def initialize(&block)
@parser = OptionParser.new
Homebrew.args = OpenStruct.new
@@ -34,10 +43,6 @@ def post_initialize
end
end
- def wrap_option_desc(desc)
- Formatter.wrap(desc, @desc_line_length).split("\n")
- end
-
def switch(*names, description: nil, env: nil, required_for: nil, depends_on: nil)
global_switch = names.first.is_a?(Symbol)
names, env, description = common_switch(*names) if global_switch
@@ -119,6 +124,10 @@ def parse(cmdline_args = ARGV)
@parser
end
+ def global_option?(name)
+ Homebrew::CLI::Parser.global_options.has_key?(name.to_sym)
+ end
+
private
def enable_switch(*names)
@@ -129,19 +138,17 @@ def enable_switch(*names)
# These are common/global switches accessible throughout Homebrew
def common_switch(name)
- case name
- when :quiet then [["-q", "--quiet"], :quiet, "Suppress any warnings."]
- when :verbose then [["-v", "--verbose"], :verbose, "Make some output more verbose."]
- when :debug then [["-d", "--debug"], :debug, "Display any debugging information."]
- when :force then [["-f", "--force"], :force, "Override warnings and enable potentially unsafe operations."]
- else name
- end
+ Homebrew::CLI::Parser.global_options.fetch(name, name)
end
def option_passed?(name)
Homebrew.args.respond_to?(name) || Homebrew.args.respond_to?("#{name}?")
end
+ def wrap_option_desc(desc)
+ Formatter.wrap(desc, @desc_line_length).split("\n")
+ end
+
def set_constraints(name, depends_on:, required_for:)
secondary = option_to_name(name)
unless required_for.nil? | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/audit.rb | @@ -55,7 +55,7 @@ module Homebrew
def audit_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### audit [options] [formulae]:
+ `audit` [`options`] [<formulae>]:
Check <formulae> for Homebrew coding style violations. This should be
run before submitting a new formula. | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/bottle.rb | @@ -72,7 +72,7 @@ module Homebrew
def bottle_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### bottle [options] [formulae]:
+ `bottle` [<options>] [<formulae>]:
Generate a bottle (binary package) from a formula installed with
`--build-bottle`. | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/bump-formula-pr.rb | @@ -50,7 +50,7 @@ module Homebrew
def bump_formula_pr_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### bump-formula-pr [options] [formula]:
+ `bump-formula-pr` [<options>] <formula>:
Creates a pull request to update the formula with a new URL or a new tag.
| true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/create.rb | @@ -30,7 +30,7 @@ module Homebrew
def create_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### create URL [options]:
+ `create` <URL> [<options>]:
Generate a formula for the downloadable file at <URL> and open it in the editor.
Homebrew will attempt to automatically derive the formula name | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/edit.rb | @@ -13,11 +13,9 @@ module Homebrew
def edit_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### edit:
- Open all of Homebrew for editing.
-
- ### edit [formula]:
- Open <formula> in the editor.
+ `edit` <formula>:
+ Open <formula> in the editor. Open all of Homebrew for editing if
+ no <formula> is provided.
EOS
switch :force
switch :verbose | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/formula.rb | @@ -10,7 +10,7 @@ module Homebrew
def formula_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### formula [formula]:
+ `formula` <formula>:
Display the path where <formula> is located.
EOS | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/irb.rb | @@ -25,7 +25,7 @@ module Homebrew
def irb_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### irb [options]:
+ `irb` [<options>]:
Enter the interactive Homebrew Ruby shell.
EOS | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/linkage.rb | @@ -22,7 +22,7 @@ module Homebrew
def linkage_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### linkage [options] [formula]:
+ `linkage` [<options>] <formula>:
Checks the library links of an installed formula.
| true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/man.rb | @@ -36,7 +36,7 @@ module Homebrew
def man_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### man [options]:
+ `man` [<options>]:
Generate Homebrew's manpages.
EOS
@@ -93,6 +93,7 @@ def build_man_page
variables[:commands] = path_glob_commands("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}")
variables[:developer_commands] = generate_cmd_manpages("#{HOMEBREW_LIBRARY_PATH}/dev-cmd/*.{rb,sh}")
+ variables[:global_options] = global_options_manpage_lines
readme = HOMEBREW_REPOSITORY/"README.md"
variables[:lead_maintainer] =
readme.read[/(Homebrew's lead maintainer .*\.)/, 1]
@@ -180,7 +181,7 @@ def generate_cmd_manpages(glob)
cmd_paths.each do |cmd_path|
begin
cmd_parser = Homebrew.send(cmd_arg_parser(cmd_path))
- man_page_lines << generate_cmd_manpage_lines(cmd_parser).join
+ man_page_lines << cmd_manpage_lines(cmd_parser).join
rescue NoMethodError
man_page_lines << path_glob_commands(cmd_path.to_s)[0]
end
@@ -192,9 +193,19 @@ def cmd_arg_parser(cmd_path)
"#{cmd_path.basename.to_s.gsub('.rb', '').gsub('-', '_')}_args".to_sym
end
- def generate_cmd_manpage_lines(cmd_parser)
- lines = [cmd_parser.usage_banner_text]
+ def cmd_manpage_lines(cmd_parser)
+ lines = ["#{format_usage_banner(cmd_parser.usage_banner_text)}"]
lines += cmd_parser.processed_options.map do |short, long, _, desc|
+ next if !long.nil? && cmd_parser.global_option?(cmd_parser.option_to_name(long))
+ generate_option_doc(short, long, desc)
+ end
+ lines
+ end
+
+ def global_options_manpage_lines
+ lines = ["These options are applicable across all sub-commands.\n"]
+ lines += Homebrew::CLI::Parser.global_options.values.map do |names, _, desc|
+ short, long = names
generate_option_doc(short, long, desc)
end
lines
@@ -211,4 +222,12 @@ def format_short_opt(opt)
def format_long_opt(opt)
"`#{opt}`"
end
+
+ def format_usage_banner(usage_banner)
+ synopsis, *remaining_lines = usage_banner.split('\n')
+ synopsis = synopsis.sub(/^/, "###")
+ .gsub(/`/, "")
+ .gsub(/<(.*?)>/, "\\1")
+ [synopsis, *remaining_lines].join("\n")
+ end
end | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/mirror.rb | @@ -10,9 +10,9 @@ module Homebrew
def mirror_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### mirror [formulae]:
+ `mirror` <formulae>:
- Reuploads the stable URL for a formula to Bintray to use it as a mirror.
+ Reuploads the stable URL for a formula to Bintray to use it as a mirror.
EOS
switch :debug
switch :verbose | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/prof.rb | @@ -1,4 +1,4 @@
-#: ### prof [ruby options]:
+#: * `prof` [ruby options]:
#: Run Homebrew with the Ruby profiler.
#: For example:
# brew prof readall | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/pull.rb | @@ -75,7 +75,7 @@ module Homebrew
def pull_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### pull [options] [formula]:
+ pull [options] [formula]:
Gets a patch from a GitHub commit or pull request and applies it to Homebrew.
Optionally, installs the formulae changed by the patch. | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/release-notes.rb | @@ -13,7 +13,7 @@ module Homebrew
def release_notes_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### release-notes [previous_tag] [end_ref]:
+ `release-notes` [<previous_tag>] [<end_ref>]:
Output the merged pull requests on Homebrew/brew between two Git refs.
If no <previous_tag> is provided it defaults to the latest tag. | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/tap-new.rb | @@ -18,7 +18,7 @@ def write_path(tap, filename, content)
def tap_new_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### tap-new [user]/[repo]:
+ `tap-new` <user>/<repo>:
Generate the template files for a new tap.
EOS | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/test.rb | @@ -1,4 +1,4 @@
-#: ### test [--devel|--HEAD] [--debug] [--keep-tmp] [formula]:
+#: * test [--devel|--HEAD] [--debug] [--keep-tmp] [formula]:
#: Most formulae provide a test method. `brew test` <formula> runs this
#: test method. There is no standard output or return code, but it should
#: generally indicate to the user if something is wrong with the installed | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/tests.rb | @@ -24,7 +24,7 @@ module Homebrew
def tests_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### tests [options] [formula]:
+ `tests` [<options>] <formula>:
Run Homebrew's unit and integration tests. If provided,
`--only=`<test_script> runs only <test_script>_spec.rb, and `--seed` | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/dev-cmd/update-test.rb | @@ -22,11 +22,11 @@ module Homebrew
def update_test_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
- ### update-test [options]:
+ `update-test` [options]:
- Runs a test of `brew update` with a new repository clone.
+ Runs a test of `brew update` with a new repository clone.
- If no arguments are passed, use `origin/master` as the start commit.
+ If no arguments are passed, use `origin/master` as the start commit.
EOS
switch "--to-tag",
description: "Set `HOMEBREW_UPDATE_TO_TAG` to test updating between tags." | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | Library/Homebrew/manpages/brew.1.md.erb | @@ -54,6 +54,10 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
<%= developer_commands.join("\n") %>
+## GLOBAL OPTIONS
+
+<%= global_options.join("\n") %>
+
## OFFICIAL EXTERNAL COMMANDS
<%= homebrew_bundle.join("\n ").strip %> | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | docs/Manpage.md | @@ -663,11 +663,11 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
## DEVELOPER COMMANDS
-### audit [options] [formulae]:
+###audit [options] [formulae]:
-Check `formulae` for Homebrew coding style violations. This should be
+Check formulae for Homebrew coding style violations. This should be
run before submitting a new formula.
-If no `formulae` are provided, all of them are checked.
+If no formulae are provided, all of them are checked.
* `--strict`:
Run additional style checks, including Rubocop style checks.
@@ -691,18 +691,14 @@ Passing `--except`=`method` will run only the methods named audit_`method`, `met
Passing `--only-cops`=`cops` will check for violations of only the listed RuboCop cops. `cops` should be a comma-separated list of cop names.
* `--except-cops`:
Passing `--except-cops`=`cops` will skip checking the listed RuboCop cops violations. `cops` should be a comma-separated list of cop names.
-* `-v`, `--verbose`:
-Make some output more verbose.
-* `-d`, `--debug`:
-Display any debugging information.
-### bottle [options] [formulae]:
+###bottle [options] [formulae]:
Generate a bottle (binary package) from a formula installed with
-`--build-bottle`.
+--build-bottle.
If the formula specifies a rebuild version, it will be incremented in the
-generated DSL. Passing `--keep-old` will attempt to keep it at its
-original value, while `--no-rebuild` will remove it.
+generated DSL. Passing --keep-old will attempt to keep it at its
+original value, while --no-rebuild will remove it.
* `--skip-relocation`:
Do not check if the bottle can be marked as relocatable.
@@ -724,20 +720,16 @@ When passed with `--write`, a new commit will not generated while writing change
Write bottle information to a JSON file, which can be used as the argument for `--merge`.
* `--root-url`:
Use the specified `URL` as the root of the bottle's URL instead of Homebrew's default.
-* `-v`, `--verbose`:
-Make some output more verbose.
-* `-d`, `--debug`:
-Display any debugging information.
-### bump-formula-pr [options] [formula]:
+###bump-formula-pr [options] formula:
Creates a pull request to update the formula with a new URL or a new tag.
-If a `URL` is specified, the `sha-256` checksum of the new download must
-also be specified. A best effort to determine the `sha-256` and `formula`
+If a URL is specified, the sha-256 checksum of the new download must
+also be specified. A best effort to determine the sha-256 and formula
name will be made if either or both values are not supplied by the user.
-If a `tag` is specified, the git commit `revision` corresponding to that
+If a tag is specified, the git commit revision corresponding to that
tag must also be specified.
Note that this command cannot be used to transition a formula from a
@@ -771,22 +763,14 @@ Use the provided `URL` as a mirror URL.
Use the provided `version` to override the value parsed from the URL or tag. Note that `--version=0` can be used to delete an existing `version` override from a formula if it has become redundant.
* `--message`:
Append provided `message` to the default PR message.
-* `-q`, `--quiet`:
-Suppress any warnings.
-* `-f`, `--force`:
-Override warnings and enable potentially unsafe operations.
-* `-v`, `--verbose`:
-Make some output more verbose.
-* `-d`, `--debug`:
-Display any debugging information.
-### create URL [options]:
+###create URL [options]:
-Generate a formula for the downloadable file at `URL` and open it in the editor.
+Generate a formula for the downloadable file at URL and open it in the editor.
Homebrew will attempt to automatically derive the formula name
-and version, but if it fails, you'll have to make your own template. The `wget`
+and version, but if it fails, you'll have to make your own template. The wget
formula serves as a simple example. For the complete API have a look at
-<http://www.rubydoc.info/github/Homebrew/brew/master/Formula>.
+http://www.rubydoc.info/github/Homebrew/brew/master/Formula.
* `--autotools`:
Create a basic template for an Autotools-style build.
@@ -804,36 +788,18 @@ Set the provided name of the package you are creating.
Set the provided version of the package you are creating.
* `--tap`:
Takes a tap [`user``/``repo`] as argument and generates the formula in the specified tap.
-* `-f`, `--force`:
-Override warnings and enable potentially unsafe operations.
-* `-v`, `--verbose`:
-Make some output more verbose.
-* `-d`, `--debug`:
-Display any debugging information.
-### edit:
- Open all of Homebrew for editing.
+###edit formula:
+ Open formula in the editor. Open all of Homebrew for editing if
+ no formula is provided.
-### edit [formula]:
- Open `formula` in the editor.
-* `-f`, `--force`:
-Override warnings and enable potentially unsafe operations.
-* `-v`, `--verbose`:
-Make some output more verbose.
-* `-d`, `--debug`:
-Display any debugging information.
+###formula formula:
-### formula [formula]:
+Display the path where formula is located.
-Display the path where `formula` is located.
-* `-d`, `--debug`:
-Display any debugging information.
-* `-v`, `--verbose`:
-Make some output more verbose.
-
-### irb [options]:
+###irb [options]:
Enter the interactive Homebrew Ruby shell.
@@ -842,7 +808,7 @@ Show several examples.
* `--pry`:
Pry will be used instead of irb if `--pry` is passed or HOMEBREW_PRY is set.
-### linkage [options] [formula]:
+###linkage [options] formula:
Checks the library links of an installed formula.
@@ -855,12 +821,8 @@ Display only missing libraries and exit with a non-zero exit code if any missing
Print the dylib followed by the binaries which link to it for each library the keg references.
* `--cached`:
Print the cached linkage values stored in HOMEBREW_CACHE, set from a previous `brew linkage` run.
-* `-v`, `--verbose`:
-Make some output more verbose.
-* `-d`, `--debug`:
-Display any debugging information.
-### man [options]:
+###man [options]:
Generate Homebrew's manpages.
@@ -869,25 +831,21 @@ Return a failing status code if changes are detected in the manpage outputs. Thi
* `--link`:
It is now done automatically by `brew update`.
-### mirror [formulae]:
+###mirror formulae:
- Reuploads the stable URL for a formula to Bintray to use it as a mirror.
+Reuploads the stable URL for a formula to Bintray to use it as a mirror.
-* `-d`, `--debug`:
-Display any debugging information.
-* `-v`, `--verbose`:
-Make some output more verbose.
- ### prof [ruby options]:
+ * `prof` [ruby options]:
Run Homebrew with the Ruby profiler.
For example:
-### pull [options] [formula]:
+###pull [options] [formula]:
Gets a patch from a GitHub commit or pull request and applies it to Homebrew.
Optionally, installs the formulae changed by the patch.
-Each `patch-source` may be one of:
+Each patch-source may be one of:
~ The ID number of a PR (pull request) in the homebrew/core GitHub
repository
@@ -922,16 +880,12 @@ Do not exit if there's a failure publishing bottles on Bintray.
Publish at the given Bintray organisation.
* `--test-bot-user`:
Pull the bottle block commit from the specified user on GitHub.
-* `-v`, `--verbose`:
-Make some output more verbose.
-* `-d`, `--debug`:
-Display any debugging information.
-### release-notes [previous_tag] [end_ref]:
+###release-notes [previous_tag] [end_ref]:
Output the merged pull requests on Homebrew/brew between two Git refs.
-If no `previous_tag` is provided it defaults to the latest tag.
-If no `end_ref` is provided it defaults to `origin/master`.
+If no previous_tag is provided it defaults to the latest tag.
+If no end_ref is provided it defaults to origin/master.
* `--markdown`:
Output as a Markdown list.
@@ -940,16 +894,12 @@ Output as a Markdown list.
Run a Ruby instance with Homebrew's libraries loaded.
For example:
-### tap-new [user]/[repo]:
+###tap-new user/repo:
Generate the template files for a new tap.
-* `-d`, `--debug`:
-Display any debugging information.
-* `-v`, `--verbose`:
-Make some output more verbose.
- ### test [--devel|--HEAD] [--debug] [--keep-tmp] [formula]:
+ * test [--devel|--HEAD] [--debug] [--keep-tmp] [formula]:
Most formulae provide a test method. `brew test` `formula` runs this
test method. There is no standard output or return code, but it should
generally indicate to the user if something is wrong with the installed
@@ -966,10 +916,10 @@ Make some output more verbose.
Example: `brew install jruby && brew test jruby`
-### tests [options] [formula]:
+###tests [options] formula:
Run Homebrew's unit and integration tests. If provided,
-`--only=``test_script` runs only `test_script`_spec.rb, and `--seed`
+--only=test_script runs only test_script_spec.rb, and --seed
randomizes tests with the provided value instead of a random seed.
* `--coverage`:
@@ -984,16 +934,12 @@ Include tests that use the GitHub API and tests that use any of the taps for off
Run only `test_script`_spec.rb
* `--seed`:
Randomizes tests with the provided value instead of a random seed.
-* `-v`, `--verbose`:
-Make some output more verbose.
-* `-d`, `--debug`:
-Display any debugging information.
-### update-test [options]:
+###update-test [options]:
- Runs a test of `brew update` with a new repository clone.
+Runs a test of brew update with a new repository clone.
- If no arguments are passed, use `origin/master` as the start commit.
+If no arguments are passed, use origin/master as the start commit.
* `--to-tag`:
Set `HOMEBREW_UPDATE_TO_TAG` to test updating between tags.
@@ -1003,11 +949,23 @@ Retain the temporary directory containing the new repository clone.
Use provided `commit` as the start commit.
* `--before`:
Use the commit at provided `date` as the start commit.
+
+## GLOBAL OPTIONS
+
+These options are applicable across all sub-commands.
+
+* `-q`, `--quiet`:
+Suppress any warnings.
+
* `-v`, `--verbose`:
Make some output more verbose.
+
* `-d`, `--debug`:
Display any debugging information.
+* `-f`, `--force`:
+Override warnings and enable potentially unsafe operations.
+
## OFFICIAL EXTERNAL COMMANDS
* `bundle` `command`:
@@ -1409,6 +1367,7 @@ See our issues on GitHub:
[ESSENTIAL COMMANDS]: #ESSENTIAL-COMMANDS "ESSENTIAL COMMANDS"
[COMMANDS]: #COMMANDS "COMMANDS"
[DEVELOPER COMMANDS]: #DEVELOPER-COMMANDS "DEVELOPER COMMANDS"
+[GLOBAL OPTIONS]: #GLOBAL-OPTIONS "GLOBAL OPTIONS"
[OFFICIAL EXTERNAL COMMANDS]: #OFFICIAL-EXTERNAL-COMMANDS "OFFICIAL EXTERNAL COMMANDS"
[CUSTOM EXTERNAL COMMANDS]: #CUSTOM-EXTERNAL-COMMANDS "CUSTOM EXTERNAL COMMANDS"
[SPECIFYING FORMULAE]: #SPECIFYING-FORMULAE "SPECIFYING FORMULAE" | true |
Other | Homebrew | brew | 446b1cb9e3c5d93c731cfc16013f1aa8cc24451a.json | man: Seperate global options into a section | manpages/brew.1 | @@ -622,7 +622,7 @@ If \fB\-\-force\fR (or \fB\-f\fR) is specified then always do a slower, full upd
.SH "DEVELOPER COMMANDS"
.
.SS "audit [options] [formulae]:"
-Check \fIformulae\fR for Homebrew coding style violations\. This should be run before submitting a new formula\. If no \fIformulae\fR are provided, all of them are checked\.
+Check formulae for Homebrew coding style violations\. This should be run before submitting a new formula\. If no formulae are provided, all of them are checked\.
.
.TP
\fB\-\-strict\fR
@@ -668,16 +668,8 @@ Passing \fB\-\-only\-cops\fR=\fIcops\fR will check for violations of only the li
\fB\-\-except\-cops\fR
Passing \fB\-\-except\-cops\fR=\fIcops\fR will skip checking the listed RuboCop cops violations\. \fBcops\fR should be a comma\-separated list of cop names\.
.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
.SS "bottle [options] [formulae]:"
-Generate a bottle (binary package) from a formula installed with \fB\-\-build\-bottle\fR\. If the formula specifies a rebuild version, it will be incremented in the generated DSL\. Passing \fB\-\-keep\-old\fR will attempt to keep it at its original value, while \fB\-\-no\-rebuild\fR will remove it\.
+Generate a bottle (binary package) from a formula installed with \-\-build\-bottle\. If the formula specifies a rebuild version, it will be incremented in the generated DSL\. Passing \-\-keep\-old will attempt to keep it at its original value, while \-\-no\-rebuild will remove it\.
.
.TP
\fB\-\-skip\-relocation\fR
@@ -719,22 +711,14 @@ Write bottle information to a JSON file, which can be used as the argument for \
\fB\-\-root\-url\fR
Use the specified \fIURL\fR as the root of the bottle\'s URL instead of Homebrew\'s default\.
.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
-.SS "bump\-formula\-pr [options] [formula]:"
+.SS "bump\-formula\-pr [options] formula:"
Creates a pull request to update the formula with a new URL or a new tag\.
.
.P
-If a \fIURL\fR is specified, the \fIsha\-256\fR checksum of the new download must also be specified\. A best effort to determine the \fIsha\-256\fR and \fIformula\fR name will be made if either or both values are not supplied by the user\.
+If a URL is specified, the sha\-256 checksum of the new download must also be specified\. A best effort to determine the sha\-256 and formula name will be made if either or both values are not supplied by the user\.
.
.P
-If a \fItag\fR is specified, the git commit \fIrevision\fR corresponding to that tag must also be specified\.
+If a tag is specified, the git commit revision corresponding to that tag must also be specified\.
.
.P
Note that this command cannot be used to transition a formula from a URL\-and\-sha256 style specification into a tag\-and\-revision style specification, nor vice versa\. It must use whichever style specification the preexisting formula already uses\.
@@ -794,24 +778,8 @@ Use the provided \fIversion\fR to override the value parsed from the URL or tag\
\fB\-\-message\fR
Append provided \fImessage\fR to the default PR message\.
.
-.TP
-\fB\-q\fR, \fB\-\-quiet\fR
-Suppress any warnings\.
-.
-.TP
-\fB\-f\fR, \fB\-\-force\fR
-Override warnings and enable potentially unsafe operations\.
-.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
.SS "create URL [options]:"
-Generate a formula for the downloadable file at \fIURL\fR and open it in the editor\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The \fBwget\fR formula serves as a simple example\. For the complete API have a look at \fIhttp://www\.rubydoc\.info/github/Homebrew/brew/master/Formula\fR\.
+Generate a formula for the downloadable file at URL and open it in the editor\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The wget formula serves as a simple example\. For the complete API have a look at http://www\.rubydoc\.info/github/Homebrew/brew/master/Formula\.
.
.TP
\fB\-\-autotools\fR
@@ -845,46 +813,11 @@ Set the provided version of the package you are creating\.
\fB\-\-tap\fR
Takes a tap [\fIuser\fR\fB/\fR\fIrepo\fR] as argument and generates the formula in the specified tap\.
.
-.TP
-\fB\-f\fR, \fB\-\-force\fR
-Override warnings and enable potentially unsafe operations\.
-.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
-.SS "edit:"
-Open all of Homebrew for editing\.
-.
-.SS "edit [formula]:"
-Open \fIformula\fR in the editor\.
-.
-.TP
-\fB\-f\fR, \fB\-\-force\fR
-Override warnings and enable potentially unsafe operations\.
-.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
-.SS "formula [formula]:"
-Display the path where \fIformula\fR is located\.
+.SS "edit formula:"
+Open formula in the editor\. Open all of Homebrew for editing if no formula is provided\.
.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
+.SS "formula formula:"
+Display the path where formula is located\.
.
.SS "irb [options]:"
Enter the interactive Homebrew Ruby shell\.
@@ -897,7 +830,7 @@ Show several examples\.
\fB\-\-pry\fR
Pry will be used instead of irb if \fB\-\-pry\fR is passed or HOMEBREW_PRY is set\.
.
-.SS "linkage [options] [formula]:"
+.SS "linkage [options] formula:"
Checks the library links of an installed formula\.
.
.P
@@ -915,14 +848,6 @@ Print the dylib followed by the binaries which link to it for each library the k
\fB\-\-cached\fR
Print the cached linkage values stored in HOMEBREW_CACHE, set from a previous \fBbrew linkage\fR run\.
.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
.SS "man [options]:"
Generate Homebrew\'s manpages\.
.
@@ -934,27 +859,18 @@ Return a failing status code if changes are detected in the manpage outputs\. Th
\fB\-\-link\fR
It is now done automatically by \fBbrew update\fR\.
.
-.SS "mirror [formulae]:"
+.SS "mirror formulae:"
Reuploads the stable URL for a formula to Bintray to use it as a mirror\.
.
.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.SS "prof [ruby options]:"
-.
-.IP
+\fBprof\fR [ruby options]
Run Homebrew with the Ruby profiler\. For example:
.
.SS "pull [options] [formula]:"
Gets a patch from a GitHub commit or pull request and applies it to Homebrew\. Optionally, installs the formulae changed by the patch\.
.
.P
-Each \fIpatch\-source\fR may be one of:
+Each patch\-source may be one of:
.
.P
~ The ID number of a PR (pull request) in the homebrew/core GitHub repository
@@ -1012,16 +928,8 @@ Publish at the given Bintray organisation\.
\fB\-\-test\-bot\-user\fR
Pull the bottle block commit from the specified user on GitHub\.
.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
.SS "release\-notes [previous_tag] [end_ref]:"
-Output the merged pull requests on Homebrew/brew between two Git refs\. If no \fIprevious_tag\fR is provided it defaults to the latest tag\. If no \fIend_ref\fR is provided it defaults to \fBorigin/master\fR\.
+Output the merged pull requests on Homebrew/brew between two Git refs\. If no previous_tag is provided it defaults to the latest tag\. If no end_ref is provided it defaults to origin/master\.
.
.TP
\fB\-\-markdown\fR
@@ -1031,20 +939,11 @@ Output as a Markdown list\.
\fBruby\fR [\fIruby options\fR]
Run a Ruby instance with Homebrew\'s libraries loaded\. For example:
.
-.SS "tap\-new [user]/[repo]:"
+.SS "tap\-new user/repo:"
Generate the template files for a new tap\.
.
.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.SS "test [\-\-devel|\-\-HEAD] [\-\-debug] [\-\-keep\-tmp] [formula]:"
-.
-.IP
+test [\-\-devel|\-\-HEAD] [\-\-debug] [\-\-keep\-tmp] [formula]
Most formulae provide a test method\. \fBbrew test\fR \fIformula\fR runs this test method\. There is no standard output or return code, but it should generally indicate to the user if something is wrong with the installed formula\.
.
.IP
@@ -1059,8 +958,8 @@ If \fB\-\-keep\-tmp\fR is passed, the temporary files created for the test are n
.IP
Example: \fBbrew install jruby && brew test jruby\fR
.
-.SS "tests [options] [formula]:"
-Run Homebrew\'s unit and integration tests\. If provided, \fB\-\-only=\fR\fItest_script\fR runs only \fItest_script\fR_spec\.rb, and \fB\-\-seed\fR randomizes tests with the provided value instead of a random seed\.
+.SS "tests [options] formula:"
+Run Homebrew\'s unit and integration tests\. If provided, \-\-only=test_script runs only test_script_spec\.rb, and \-\-seed randomizes tests with the provided value instead of a random seed\.
.
.TP
\fB\-\-coverage\fR
@@ -1086,19 +985,11 @@ Run only \fItest_script\fR_spec\.rb
\fB\-\-seed\fR
Randomizes tests with the provided value instead of a random seed\.
.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-Make some output more verbose\.
-.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-Display any debugging information\.
-.
.SS "update\-test [options]:"
-Runs a test of \fBbrew update\fR with a new repository clone\.
+Runs a test of brew update with a new repository clone\.
.
.P
-If no arguments are passed, use \fBorigin/master\fR as the start commit\.
+If no arguments are passed, use origin/master as the start commit\.
.
.TP
\fB\-\-to\-tag\fR
@@ -1116,6 +1007,13 @@ Use provided \fIcommit\fR as the start commit\.
\fB\-\-before\fR
Use the commit at provided \fIdate\fR as the start commit\.
.
+.SH "GLOBAL OPTIONS"
+These options are applicable across all sub\-commands\.
+.
+.TP
+\fB\-q\fR, \fB\-\-quiet\fR
+Suppress any warnings\.
+.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Make some output more verbose\.
@@ -1124,6 +1022,10 @@ Make some output more verbose\.
\fB\-d\fR, \fB\-\-debug\fR
Display any debugging information\.
.
+.TP
+\fB\-f\fR, \fB\-\-force\fR
+Override warnings and enable potentially unsafe operations\.
+.
.SH "OFFICIAL EXTERNAL COMMANDS"
.
.TP | true |
Other | Homebrew | brew | cfaaa0eb71acc9ffea245594a0a82ecde5b3c09b.json | Move option descriptions to new line | Library/Homebrew/cli_parser.rb | @@ -30,6 +30,7 @@ def post_initialize
.gsub(/`(.*?)`/, "#{Tty.bold}\\1#{Tty.reset}")
.gsub(%r{<([^\s]+?://[^\s]+?)>}) { |url| Formatter.url(url) }
.gsub(/<(.*?)>/, "#{Tty.underline}\\1#{Tty.reset}")
+ exit
end
end
@@ -54,7 +55,7 @@ def switch(*names, description: nil, env: nil, required_for: nil, depends_on: ni
end
def usage_banner(text)
- @parser.banner = text
+ @parser.banner = "#{text}\n"
end
def usage_banner_text | true |
Other | Homebrew | brew | cfaaa0eb71acc9ffea245594a0a82ecde5b3c09b.json | Move option descriptions to new line | Library/Homebrew/dev-cmd/audit.rb | @@ -61,41 +61,38 @@ def audit_args
run before submitting a new formula.
If no <formulae> are provided, all of them are checked.
-
EOS
- switch "--strict", description: "Run additional style checks, "\
- "including Rubocop style checks."
- switch "--online", description: "Run additional slower style checks "\
- "that require a network connection."
- switch "--new-formula", description: "Run various additional style checks "\
- "to determine if a new formula is eligible "\
- "for Homebrew. This should be used when "\
- "creating new formula and implies "\
- "`--strict` and `--online`."
- switch "--fix", description: "Fix style violations automatically using "\
- "RuboCop's auto-correct feature."
- switch "--display-cop-names", description: "Include the RuboCop cop name for each "\
- "violation in the output."
- switch "--display-filename", description: "Prefix everyline of output with name of "\
- "the file or formula being audited, to "\
- "make output easy to grep."
- switch "-D", "--audit-debug", description: "Activates debugging and profiling"
- comma_array "--only", description: "Passing `--only`=<method> will run only the"\
- "methods named audit_method, `method` should "\
- "be a comma-separated list."
- comma_array "--except", description: "Passing `--except`=<method> will run only the "\
- "methods named audit_method, `method` should "\
- "be a comma-separated list."
- comma_array "--only-cops", description: "Passing `--only-cops`=<cops> will check for "\
- "violations of only the listed RuboCop cops."\
- "`cops` should be a comma-separated list of "\
- "cop names."
- comma_array "--except-cops", description: "Passing `--except-cops`=<cops> will "\
- "skip checking the listed RuboCop cops "\
- "violations. `cops` should be a "\
- "comma-separated list of cop names."
- switch :verbose
- switch :debug
+ switch "--strict",
+ description: "Run additional style checks, including Rubocop style checks."
+ switch "--online",
+ description: "Run additional slower style checks that require a network connection."
+ switch "--new-formula",
+ description: "Run various additional style checks to determine if a new formula is eligible "\
+ "for Homebrew. This should be used when creating new formula and implies "\
+ "`--strict` and `--online`."
+ switch "--fix",
+ description: "Fix style violations automatically using RuboCop's auto-correct feature."
+ switch "--display-cop-names",
+ description: "Include the RuboCop cop name for each violation in the output."
+ switch "--display-filename",
+ description: "Prefix everyline of output with name of the file or formula being audited, to "\
+ "make output easy to grep."
+ switch "-D", "--audit-debug",
+ description: "Activates debugging and profiling"
+ comma_array "--only",
+ description: "Passing `--only`=<method> will run only the methods named audit_<method>, `method` "\
+ "should be a comma-separated list."
+ comma_array "--except",
+ description: "Passing `--except`=<method> will run only the methods named audit_<method>, "\
+ "`method` should be a comma-separated list."
+ comma_array "--only-cops",
+ description: "Passing `--only-cops`=<cops> will check for violations of only the listed "\
+ "RuboCop cops. `cops` should be a comma-separated list of cop names."
+ comma_array "--except-cops",
+ description: "Passing `--except-cops`=<cops> will skip checking the listed RuboCop cops "\
+ "violations. `cops` should be a comma-separated list of cop names."
+ switch :verbose
+ switch :debug
end
end
| true |
Other | Homebrew | brew | cfaaa0eb71acc9ffea245594a0a82ecde5b3c09b.json | Move option descriptions to new line | Library/Homebrew/dev-cmd/man.rb | @@ -168,6 +168,6 @@ def format_short_opt(opt)
end
def format_long_opt(opt)
- "`#{opt}`".ljust(30)
+ "`#{opt}`"
end
end | true |
Other | Homebrew | brew | cfaaa0eb71acc9ffea245594a0a82ecde5b3c09b.json | Move option descriptions to new line | docs/Manpage.md | @@ -671,43 +671,43 @@ run before submitting a new formula.
If no `formulae` are provided, all of them are checked.
-* `--strict` :
+* `--strict`:
Run additional style checks, including Rubocop style checks.
-* `--online` :
+* `--online`:
Run additional slower style checks that require a network connection.
-* `--new-formula` :
+* `--new-formula`:
Run various additional style checks to determine if a new formula is eligible for Homebrew. This should be used when creating new formula and implies `--strict` and `--online`.
-* `--fix` :
+* `--fix`:
Fix style violations automatically using RuboCop's auto-correct feature.
-* `--display-cop-names` :
+* `--display-cop-names`:
Include the RuboCop cop name for each violation in the output.
-* `--display-filename` :
+* `--display-filename`:
Prefix everyline of output with name of the file or formula being audited, to make output easy to grep.
-* `-D`, `--audit-debug` :
+* `-D`, `--audit-debug`:
Activates debugging and profiling
-* `--only` :
-Passing `--only`=`method` will run only themethods named audit_method, `method` should be a comma-separated list.
+* `--only`:
+Passing `--only`=`method` will run only the methods named audit_`method`, `method` should be a comma-separated list.
-* `--except` :
-Passing `--except`=`method` will run only the methods named audit_method, `method` should be a comma-separated list.
+* `--except`:
+Passing `--except`=`method` will run only the methods named audit_`method`, `method` should be a comma-separated list.
-* `--only-cops` :
-Passing `--only-cops`=`cops` will check for violations of only the listed RuboCop cops.`cops` should be a comma-separated list of cop names.
+* `--only-cops`:
+Passing `--only-cops`=`cops` will check for violations of only the listed RuboCop cops. `cops` should be a comma-separated list of cop names.
-* `--except-cops` :
+* `--except-cops`:
Passing `--except-cops`=`cops` will skip checking the listed RuboCop cops violations. `cops` should be a comma-separated list of cop names.
-* `-v`, `--verbose` :
+* `-v`, `--verbose`:
Make some output more verbose.
-* `-d`, `--debug` :
+* `-d`, `--debug`:
Display any debugging information.
* `audit` [`--strict`] [`--fix`] [`--online`] [`--new-formula`] [`--display-cop-names`] [`--display-filename`] [`--only=``method`|`--except=``method`] [`--only-cops=``cops`|`--except-cops=``cops`] [`formulae`]: | true |
Other | Homebrew | brew | cfaaa0eb71acc9ffea245594a0a82ecde5b3c09b.json | Move option descriptions to new line | manpages/brew.1 | @@ -639,15 +639,15 @@ Activates debugging and profiling
.
.TP
\fB\-\-only\fR
-Passing \fB\-\-only\fR=\fImethod\fR will run only themethods named audit_method, \fBmethod\fR should be a comma\-separated list\.
+Passing \fB\-\-only\fR=\fImethod\fR will run only the methods named audit_\fImethod\fR, \fBmethod\fR should be a comma\-separated list\.
.
.TP
\fB\-\-except\fR
-Passing \fB\-\-except\fR=\fImethod\fR will run only the methods named audit_method, \fBmethod\fR should be a comma\-separated list\.
+Passing \fB\-\-except\fR=\fImethod\fR will run only the methods named audit_\fImethod\fR, \fBmethod\fR should be a comma\-separated list\.
.
.TP
\fB\-\-only\-cops\fR
-Passing \fB\-\-only\-cops\fR=\fIcops\fR will check for violations of only the listed RuboCop cops\.\fBcops\fR should be a comma\-separated list of cop names\.
+Passing \fB\-\-only\-cops\fR=\fIcops\fR will check for violations of only the listed RuboCop cops\. \fBcops\fR should be a comma\-separated list of cop names\.
.
.TP
\fB\-\-except\-cops\fR | true |
Other | Homebrew | brew | 32e5a5686bf73cb165e750f0ee8715ca9d9b8fac.json | audit: Use OptionParser to generate help text | Library/Homebrew/brew.rb | @@ -73,7 +73,7 @@
# - a help flag is passed AND there is no command specified
# - no arguments are passed
# - if cmd is Cask, let Cask handle the help command instead
- if (empty_argv || help_flag) && cmd != "cask"
+ if (empty_argv || help_flag) && cmd != "cask" && !internal_dev_cmd
require "help"
Homebrew::Help.help cmd, empty_argv: empty_argv
# `Homebrew.help` never returns, except for external/unknown commands. | true |
Other | Homebrew | brew | 32e5a5686bf73cb165e750f0ee8715ca9d9b8fac.json | audit: Use OptionParser to generate help text | Library/Homebrew/cli_parser.rb | @@ -17,13 +17,21 @@ def initialize(&block)
@constraints = []
@conflicts = []
instance_eval(&block)
+ post_initialize
+ end
+
+ def post_initialize
+ @parser.on_tail("-h", "--help", "Show this message") do
+ puts @parser
+ exit
+ end
end
def switch(*names, description: nil, env: nil, required_for: nil, depends_on: nil)
- description = option_to_description(*names) if description.nil?
global_switch = names.first.is_a?(Symbol)
- names, env = common_switch(*names) if global_switch
- @parser.on(*names, description) do
+ names, env, description = common_switch(*names) if global_switch
+ description = option_to_description(*names) if description.nil?
+ @parser.on(*names, *description.split("\n")) do
enable_switch(*names)
end
@@ -34,9 +42,13 @@ def switch(*names, description: nil, env: nil, required_for: nil, depends_on: ni
enable_switch(*names) if !env.nil? && !ENV["HOMEBREW_#{env.to_s.upcase}"].nil?
end
+ def banner(text)
+ @parser.banner = text
+ end
+
def comma_array(name, description: nil)
description = option_to_description(name) if description.nil?
- @parser.on(name, OptionParser::REQUIRED_ARGUMENT, Array, description) do |list|
+ @parser.on(name, OptionParser::REQUIRED_ARGUMENT, Array, *description.split("\n")) do |list|
Homebrew.args[option_to_name(name)] = list
end
end
@@ -49,7 +61,7 @@ def flag(name, description: nil, required_for: nil, depends_on: nil)
required = OptionParser::OPTIONAL_ARGUMENT
end
description = option_to_description(name) if description.nil?
- @parser.on(name, description, required) do |option_value|
+ @parser.on(name, *description.split("\n"), required) do |option_value|
Homebrew.args[option_to_name(name)] = option_value
end
@@ -78,6 +90,10 @@ def option_to_description(*names)
names.map { |name| name.to_s.sub(/\A--?/, "").tr("-", " ") }.max
end
+ def summary
+ @parser.to_s
+ end
+
def parse(cmdline_args)
remaining_args = @parser.parse(cmdline_args)
check_constraint_violations
@@ -95,10 +111,10 @@ def enable_switch(*names)
# These are common/global switches accessible throughout Homebrew
def common_switch(name)
case name
- when :quiet then [["-q", "--quiet"], :quiet]
- when :verbose then [["-v", "--verbose"], :verbose]
- when :debug then [["-d", "--debug"], :debug]
- when :force then [["-f", "--force"], :force]
+ when :quiet then [["-q", "--quiet"], :quiet, "Suppress warnings."]
+ when :verbose then [["-v", "--verbose"], :verbose, "Verbose mode."]
+ when :debug then [["-d", "--debug"], :debug, "Display debug info."]
+ when :force then [["-f", "--force"], :force, "Override any warnings/validations."]
else name
end
end | true |
Other | Homebrew | brew | 32e5a5686bf73cb165e750f0ee8715ca9d9b8fac.json | audit: Use OptionParser to generate help text | Library/Homebrew/dev-cmd/audit.rb | @@ -54,19 +54,27 @@ module Homebrew
def audit
Homebrew::CLI::Parser.parse do
- switch "--strict"
- switch "--online"
- switch "--new-formula"
- switch "--fix"
- switch "--display-cop-names"
- switch "--display-filename"
+ banner <<~EOS
+ Usage: brew audit [options] [<formulae>]
+
+ Check <formulae> for Homebrew coding style violations. This should be
+ run before submitting a new formula.
+
+ If no <formulae> are provided, all of them are checked.
+ EOS
+ switch "--strict", description: "Run additional style checks, including Rubocop style checks."
+ switch "--online", description: "Run additional slower style checks that require a\nnetwork connection."
+ switch "--new-formula", description: "Run various additional style checks to determine if a new formula \nis eligible for Homebrew. This should be used when creating \nnew formula and implies --strict and --online."
+ switch "--fix", description: "Fix style violations automatically using\nRuboCop's auto-correct feature."
+ switch "--display-cop-names", description: "Include the RuboCop cop name for each violation\nin the output."
+ switch "--display-filename", description: "Prefix everyline of output with name of the file or\nformula being audited, to make output easy to grep."
switch "-D", "--audit-debug", description: "Activates debugging and profiling"
+ comma_array "--only", description: "Passing --only=method will run only the methods named audit_method,\n`method` should be a comma-separated list."
+ comma_array "--except", description: "Passing --except=method will run only the methods named audit_method,\n`method` should be a comma-separated list."
+ comma_array "--only-cops", description: "Passing --only-cops=cops will check for violations of only the listed\nRuboCop cops. `cops` should be a comma-separated list of cop names."
+ comma_array "--except-cops", description: "Passing --except-cops=cops will skip checking the listed\nRuboCop cops violations. `cops` should be a comma-separated list of cop names."
switch :verbose
switch :debug
- comma_array "--only"
- comma_array "--except"
- comma_array "--only-cops"
- comma_array "--except-cops"
end
Homebrew.auditing = true | true |
Other | Homebrew | brew | fdcdf7cb5c2bd86e2ab8943bcabf0a96cb6e0c82.json | CoreTap.default_remote: Use Linuxbrew/core [Linux] | Library/Homebrew/cmd/update.sh | @@ -24,7 +24,12 @@ git() {
git_init_if_necessary() {
BREW_OFFICIAL_REMOTE="https://github.com/Homebrew/brew"
- CORE_OFFICIAL_REMOTE="https://github.com/Homebrew/homebrew-core"
+ if [[ -n "$HOMEBREW_MACOS" ]] || [[ -n "$HOMEBREW_FORCE_HOMEBREW_ORG" ]]
+ then
+ CORE_OFFICIAL_REMOTE="https://github.com/Homebrew/homebrew-core"
+ else
+ CORE_OFFICIAL_REMOTE="https://github.com/Linuxbrew/homebrew-core"
+ fi
safe_cd "$HOMEBREW_REPOSITORY"
if [[ ! -d ".git" ]] | true |
Other | Homebrew | brew | fdcdf7cb5c2bd86e2ab8943bcabf0a96cb6e0c82.json | CoreTap.default_remote: Use Linuxbrew/core [Linux] | Library/Homebrew/extend/os/linux/tap.rb | @@ -0,0 +1,9 @@
+class CoreTap < Tap
+ def default_remote
+ if ENV["HOMEBREW_FORCE_HOMEBREW_ORG"]
+ "https://github.com/Homebrew/homebrew-core".freeze
+ else
+ "https://github.com/Linuxbrew/homebrew-core".freeze
+ end
+ end
+end | true |
Other | Homebrew | brew | fdcdf7cb5c2bd86e2ab8943bcabf0a96cb6e0c82.json | CoreTap.default_remote: Use Linuxbrew/core [Linux] | Library/Homebrew/extend/os/tap.rb | @@ -0,0 +1 @@
+require "extend/os/linux/tap" if OS.linux? | true |
Other | Homebrew | brew | fdcdf7cb5c2bd86e2ab8943bcabf0a96cb6e0c82.json | CoreTap.default_remote: Use Linuxbrew/core [Linux] | Library/Homebrew/tap.rb | @@ -735,3 +735,5 @@ def []=(key, value)
end
end
end
+
+require "extend/os/tap" | true |
Other | Homebrew | brew | 447baab9a05ca7f860a70adf52017ec69e687a8b.json | DevelopmentTools::locate: Prefer brewed tools [Linux] | Library/Homebrew/extend/os/linux/development_tools.rb | @@ -1,5 +1,15 @@
class DevelopmentTools
class << self
+ def locate(tool)
+ (@locate ||= {}).fetch(tool) do |key|
+ @locate[key] = if (path = HOMEBREW_PREFIX/"bin/#{tool}").executable?
+ path
+ elsif File.executable?(path = "/usr/bin/#{tool}")
+ Pathname.new path
+ end
+ end
+ end
+
def default_compiler
:gcc
end | false |
Other | Homebrew | brew | 292361eaf04be33a2b6641dde9fb01701637870f.json | docs: move sample commands into code blocks | docs/How-To-Open-a-Homebrew-Pull-Request.md | @@ -2,7 +2,7 @@
The following commands are used by Homebrew contributors to set up a fork of Homebrew's Git repository on GitHub, create a new branch and create a GitHub pull request ("PR") of the changes in that branch.
-Depending on the change you want to make, you need to send the pull request to the appropriate one of Homebrew's main repositories. If you want to submit a change to Homebrew core code (the `brew` implementation), you should open the pull request on [Homebrew/brew](https://github.com/Homebrew/brew). If you want to submit a change for a formula, you should open the pull request on [the `homebrew/core` tap](https://github.com/Homebrew/homebrew-core) or another [official tap](https://github.com/Homebrew), based on the formula type.
+Depending on the change you want to make, you need to send the pull request to the appropriate one of Homebrew's main repositories. If you want to submit a change to Homebrew core code (the `brew` implementation), you should open the pull request on [Homebrew/brew](https://github.com/Homebrew/brew). If you want to submit a change for a formula, you should open the pull request on the [homebrew/core](https://github.com/Homebrew/homebrew-core) tap or another [official tap](https://github.com/Homebrew), based on the formula type.
## Submit a new version of an existing formula
1. Use `brew bump-formula-pr` to do everything (i.e. forking, committing, pushing) with a single command. Run `brew bump-formula-pr --help` to learn more.
@@ -13,36 +13,62 @@ Depending on the change you want to make, you need to send the pull request to t
1. [Fork the Homebrew/brew repository on GitHub](https://github.com/Homebrew/brew/fork).
* This creates a personal remote repository that you can push to. This is needed because only Homebrew maintainers have push access to the main repositories.
-2. Change to the directory containing your Homebrew installation with `cd $(brew --repository)`.
-3. Add your pushable forked repository with `git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/brew.git`.
+2. Change to the directory containing your Homebrew installation:
+ ```sh
+ cd $(brew --repository)
+ ```
+3. Add your pushable forked repository as a new remote:
+ ```sh
+ git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/brew.git
+ ```
* `<YOUR_USERNAME>` is your GitHub username, not your local machine username.
### Formulae related pull request
1. [Fork the Homebrew/homebrew-core repository on GitHub](https://github.com/Homebrew/homebrew-core/fork).
* This creates a personal remote repository that you can push to. This is needed because only Homebrew maintainers have push access to the main repositories.
-2. Change to the directory containing Homebrew formulae with `cd $(brew --repository homebrew/core)`.
-3. Add your pushable forked repository with `git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/homebrew-core.git`
+2. Change to the directory containing Homebrew formulae:
+ ```sh
+ cd $(brew --repository homebrew/core)
+ ```
+3. Add your pushable forked repository as a new remote:
+ ```sh
+ git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/homebrew-core.git
+ ```
* `<YOUR_USERNAME>` is your GitHub username, not your local machine username.
## Create your pull request from a new branch
To make a new branch and submit it for review, create a GitHub pull request with the following steps:
-1. Check out the `master` branch with `git checkout master`.
-2. Retrieve new changes to the `master` branch with `brew update`.
-3. Create a new branch from the latest `master` branch with `git checkout -b <YOUR_BRANCH_NAME> origin/master`.
+1. Check out the `master` branch:
+ ```sh
+ git checkout master
+ ```
+2. Retrieve new changes to the `master` branch:
+ ```sh
+ brew update
+ ```
+3. Create a new branch from the latest `master` branch:
+ ```sh
+ git checkout -b <YOUR_BRANCH_NAME> origin/master
+ ```
4. Make your changes. For formulae, use `brew edit` or your favourite text editor, following all the guidelines in the [Formula Cookbook](Formula-Cookbook.md).
* If there's a `bottle do` block in the formula, don't remove or change it; we'll update it when we pull your PR.
-5. Test your changes by doing the following, and ensure they all pass without issue. For changed formulae, make sure you do the `brew audit` step while your changed formula is installed.
- * `brew tests`
- * `brew install --build-from-source <CHANGED_FORMULA>`
- * `brew test <CHANGED_FORMULA>`
- * `brew audit --strict <CHANGED_FORMULA>`
-6. Make a separate commit for each changed formula with `git add` and `git commit`.
-7. Upload your new commits to the branch on your fork with `git push --set-upstream <YOUR_USERNAME> <YOUR_BRANCH_NAME>`.
+5. Test your changes by running the following, and ensure they all pass without issue. For changed formulae, make sure you do the `brew audit` step while your changed formula is installed.
+ ```sh
+ brew tests
+ brew install --build-from-source <CHANGED_FORMULA>
+ brew test <CHANGED_FORMULA>
+ brew audit --strict <CHANGED_FORMULA>
+ ```
+6. [Make a separate commit](Formula-Cookbook.md#commit) for each changed formula with `git add` and `git commit`.
+ * Please note that our preferred commit message format for simple version updates is "`<FORMULA_NAME> <NEW_VERSION>`", e.g. "`source-highlight 3.1.8`" but `devel` version updates should have the commit message suffixed with `(devel)`, e.g. "`nginx 1.9.1 (devel)`". If updating both `stable` and `devel`, the format should be a concatenation of these two forms, e.g. "`x264 r2699, r2705 (devel)`".
+7. Upload your branch of new commits to your fork:
+ ```sh
+ git push --set-upstream <YOUR_USERNAME> <YOUR_BRANCH_NAME>
+ ```
8. Go to the relevant repository (e.g. <https://github.com/Homebrew/brew>, <https://github.com/Homebrew/homebrew-core>, etc.) and create a pull request to request review and merging of the commits in your pushed branch. Explain why the change is needed and, if fixing a bug, how to reproduce the bug. Make sure you have done each step in the checklist that appears in your new PR.
- * Please note that our preferred commit message format for simple version updates is "`<FORMULA_NAME> <NEW_VERSION>`", e.g. "`source-highlight 3.1.8`". `devel` version updates should have the commit message suffixed with `(devel)`, e.g. "`nginx 1.9.1 (devel)`". If updating both `stable` and `devel`, the format should be a concatenation of these two forms, e.g. "`x264 r2699, r2705 (devel)`".
9. Await feedback or a merge from Homebrew's maintainers. We typically respond to all PRs within a couple days, but it may take up to a week, depending on the maintainers' workload.
Thank you!
@@ -60,12 +86,20 @@ To respond well to feedback:
To make changes based on feedback:
-1. Check out your branch again with `git checkout <YOUR_BRANCH_NAME>`.
+1. Check out your branch again:
+ ```sh
+ git checkout <YOUR_BRANCH_NAME>
+ ```
2. Make any requested changes and commit them with `git add` and `git commit`.
-3. Squash new commits into one commit per formula with `git rebase --interactive origin/master`.
-4. Push to your remote fork's branch and the pull request with `git push --force`.
-
-If you are working on a PR for a single formula, `git commit --amend` is a convenient way of keeping your commits squashed as you go.
+3. Squash new commits into one commit per formula:
+ ```sh
+ git rebase --interactive origin/master
+ ```
+ * If you are working on a PR for a single formula, `git commit --amend` is a convenient way of keeping your commits squashed as you go.
+4. Push to your remote fork's branch and the pull request:
+ ```sh
+ git push --force
+ ```
Once all feedback has been addressed and if it's a change we want to include (we include most changes), then we'll add your commit to Homebrew. Note that the PR status may show up as "Closed" instead of "Merged" because of the way we merge contributions. Don't worry: you will still get author credit in the actual merged commit.
| false |
Other | Homebrew | brew | 78ddc34847983002609bd1991b68df0437a88000.json | config: hide optional system packages.
Java, XQuartz and the CLT separate header package aren't required for
everyone's Homebrew usage or a default macOS development install.
As a result, only show then in `brew config` when they are actually
installed. | Library/Homebrew/extend/os/mac/system_config.rb | @@ -57,11 +57,9 @@ def dump_verbose_config(f = $stdout)
dump_generic_verbose_config(f)
f.puts "macOS: #{MacOS.full_version}-#{kernel}"
f.puts "CLT: #{clt || "N/A"}"
- if MacOS::CLT.separate_header_package?
- f.puts "CLT headers: #{clt_headers || "N/A"}"
- end
f.puts "Xcode: #{xcode || "N/A"}"
- f.puts "XQuartz: #{xquartz || "N/A"}"
+ f.puts "CLT headers: #{clt_headers}" if MacOS::CLT.separate_header_package? && clt_headers
+ f.puts "XQuartz: #{xquartz}" if !MacOS::XQuartz.provided_by_apple? && xquartz
end
end
end | true |
Other | Homebrew | brew | 78ddc34847983002609bd1991b68df0437a88000.json | config: hide optional system packages.
Java, XQuartz and the CLT separate header package aren't required for
everyone's Homebrew usage or a default macOS development install.
As a result, only show then in `brew config` when they are actually
installed. | Library/Homebrew/system_config.rb | @@ -196,7 +196,7 @@ def dump_verbose_config(f = $stdout)
end
f.puts "Git: #{describe_git}"
f.puts "Curl: #{describe_curl}"
- f.puts "Java: #{describe_java}"
+ f.puts "Java: #{describe_java}" if describe_java != "N/A"
end
alias dump_generic_verbose_config dump_verbose_config
end | true |
Other | Homebrew | brew | 25b9a7d35bb5a4615df2509f3f29c2542c0c574d.json | rubocop: move requirement to configuration file
If you are using en external rubocop binary you will encounter the
following error.
.rubocop_todo.yml: RSpec/FilePath has the wrong namespace - should be Rails
By moving the option to the config file an external rubocop would be
treated equally to brew style without having to supply additional
command line options. | Library/.rubocop.yml | @@ -5,7 +5,9 @@ AllCops:
- '**/vendor/**/*'
DisplayCopNames: false
-require: ./Homebrew/rubocops.rb
+require:
+ - rubocop-rspec
+ - ./Homebrew/rubocops.rb
# enable all formulae audits
FormulaAudit: | true |
Other | Homebrew | brew | 25b9a7d35bb5a4615df2509f3f29c2542c0c574d.json | rubocop: move requirement to configuration file
If you are using en external rubocop binary you will encounter the
following error.
.rubocop_todo.yml: RSpec/FilePath has the wrong namespace - should be Rails
By moving the option to the config file an external rubocop would be
treated equally to brew style without having to supply additional
command line options. | Library/Homebrew/style.rb | @@ -23,7 +23,6 @@ def check_style_impl(files, output_type, options = {})
require "rubocops"
args = %w[
- --require rubocop-rspec
--force-exclusion
]
if fix | true |
Other | Homebrew | brew | 9a4b54f85d076e1d7eefe45f1db510b19339915e.json | Remove dbm_test_read analytics.
This can now be removed because my paranoia was unjustified and it's
successful 99.93% of the time. | Library/Homebrew/cache_store.rb | @@ -97,7 +97,6 @@ def db
end
false
end
- Utils::Analytics.report_event("dbm_test_read", dbm_test_read_success.to_s)
cache_path.delete unless dbm_test_read_success
end
DBM.open(dbm_file_path, DATABASE_MODE, DBM::WRCREAT) | true |
Other | Homebrew | brew | 9a4b54f85d076e1d7eefe45f1db510b19339915e.json | Remove dbm_test_read analytics.
This can now be removed because my paranoia was unjustified and it's
successful 99.93% of the time. | docs/Analytics.md | @@ -29,7 +29,6 @@ Homebrew's analytics records the following different events:
- an `event` hit type with the `install_on_request` event category and the Homebrew formula from a non-private GitHub tap you have requested to install (e.g. explicitly named it with a `brew install`) plus options and an event label as above. This allows us to differentiate the formulae that users intend to install from those pulled in as dependencies.
- an `event` hit type with the `cask_install` event category and the Homebrew cask from a non-private GitHub tap you install as the action and an event label as above. This allows us to identify the casks that need fixing and where more easily.
- an `event` hit type with the `BuildError` event category and the Homebrew formula that failed to install, e.g. `wget` as the action and an event label e.g. `macOS 10.12`.
-- an `event` hit type with the `dbm_test_read` event category and `true` or `false` as the action (depending on if a corrupt DBM database was detected) and an event label e.g. `macOS 10.12`.
You can also view all the information that is sent by Homebrew's analytics by setting `HOMEBREW_ANALYTICS_DEBUG=1` in your environment. Please note this will also stop any analytics from being sent.
| true |
Other | Homebrew | brew | 3ce4caeb1aa8d5b9cd818bc114b4810b717ced3b.json | Add tests for language/python | Library/Homebrew/test/language/python_spec.rb | @@ -1,6 +1,35 @@
require "language/python"
require "resource"
+describe Language::Python, :needs_python do
+ describe "#major_minor_version" do
+ it "returns a Version for Python 2" do
+ expect(subject).to receive(:major_minor_version).and_return(Version)
+ subject.major_minor_version("python")
+ end
+ end
+
+ describe "#site_packages" do
+ it "gives a different location between PyPy and Python 2" do
+ expect(subject.site_packages("python")).not_to eql(subject.site_packages("pypy"))
+ end
+ end
+
+ describe "#homebrew_site_packages" do
+ it "returns the Homebrew site packages location" do
+ expect(subject).to receive(:site_packages).and_return(Pathname)
+ subject.site_packages("python")
+ end
+ end
+
+ describe "#user_site_packages" do
+ it "can determine user site packages location" do
+ expect(subject).to receive(:user_site_packages).and_return(Pathname)
+ subject.user_site_packages("python")
+ end
+ end
+end
+
describe Language::Python::Virtualenv::Virtualenv do
subject { described_class.new(formula, dir, "python") }
| false |
Other | Homebrew | brew | 876021a926f9ef1ba6c555353f7a43678e97fb8b.json | prune: preserve some directories
Some directories, while empty, are created in brew upgrade and
should be kept. | Library/Homebrew/cmd/prune.rb | @@ -32,7 +32,8 @@ def prune
path.unlink
end
end
- elsif path.directory? && !Keg::PRUNEABLE_DIRECTORIES.include?(path)
+ elsif path.directory? && !Keg::PRUNEABLE_DIRECTORIES.include?(path) &&
+ !Keg::MUST_BE_WRITABLE_DIRECTORIES.include?(path)
dirs << path
end
end | false |
Other | Homebrew | brew | f99f1b611fbc8f37eecdf465bdc21a4ceb101f20.json | cache_store_spec: fix bad rebase.
https://github.com/Homebrew/brew/pull/4948#discussion_r219276137 | Library/Homebrew/test/cache_store_spec.rb | @@ -124,7 +124,7 @@
allow(subject).to receive(:cache_path).and_return(cache_path)
end
- context "`File.exist?(cache_path)` returns `true`" do
+ context "`cache_path.exist?` returns `true`" do
before do
allow(cache_path).to receive(:exist?).and_return(true)
end
@@ -134,7 +134,7 @@
end
end
- context "`File.exist?(cache_path)` returns `false`" do
+ context "`cache_path.exist?` returns `false`" do
before do
allow(cache_path).to receive(:exist?).and_return(false)
end | false |
Other | Homebrew | brew | 752714b71ceeb473bdbdb008e645c645cb428d96.json | cache_store: add dbm_test_read analytics. | Library/Homebrew/cache_store.rb | @@ -97,6 +97,7 @@ def db
end
false
end
+ Utils::Analytics.report_event("dbm_test_read", dbm_test_read_success.to_s)
cache_path.delete unless dbm_test_read_success
end
DBM.open(dbm_file_path, DATABASE_MODE, DBM::WRCREAT) | true |
Other | Homebrew | brew | 752714b71ceeb473bdbdb008e645c645cb428d96.json | cache_store: add dbm_test_read analytics. | docs/Analytics.md | @@ -28,7 +28,8 @@ Homebrew's analytics records the following different events:
- an `event` hit type with the `install` event category and the Homebrew formula from a non-private GitHub tap you install plus any used options, e.g. `wget --with-pcre` as the action and an event label e.g. `macOS 10.12, non-/usr/local, CI` to indicate the OS version, non-standard installation location and invocation as part of CI. This allows us to identify the formulae that need fixing and where more easily.
- an `event` hit type with the `install_on_request` event category and the Homebrew formula from a non-private GitHub tap you have requested to install (e.g. explicitly named it with a `brew install`) plus options and an event label as above. This allows us to differentiate the formulae that users intend to install from those pulled in as dependencies.
- an `event` hit type with the `cask_install` event category and the Homebrew cask from a non-private GitHub tap you install as the action and an event label as above. This allows us to identify the casks that need fixing and where more easily.
-- an `event` hit type with the `BuildError` event category and the Homebrew formula that failed to install, e.g. `wget` as the action and an event label e.g. `macOS 10.12`
+- an `event` hit type with the `BuildError` event category and the Homebrew formula that failed to install, e.g. `wget` as the action and an event label e.g. `macOS 10.12`.
+- an `event` hit type with the `dbm_test_read` event category and `true` or `false` as the action (depending on if a corrupt DBM database was detected) and an event label e.g. `macOS 10.12`.
You can also view all the information that is sent by Homebrew's analytics by setting `HOMEBREW_ANALYTICS_DEBUG=1` in your environment. Please note this will also stop any analytics from being sent.
| true |
Other | Homebrew | brew | 7eb4b92d309a2118881f78893271bc1c8e5d57b4.json | cache_store: handle missing process.
If we try to kill the process but it's already dead just ignore it. | Library/Homebrew/cache_store.rb | @@ -89,7 +89,12 @@ def db
end
rescue ErrorDuringExecution, Timeout::Error
odebug "Failed to read #{dbm_file_path}!"
- Process.kill(:KILL, dbm_test_read_cmd.pid)
+ begin
+ Process.kill(:KILL, dbm_test_read_cmd.pid)
+ rescue Errno::ESRCH
+ # Process has already terminated.
+ nil
+ end
false
end
cache_path.delete unless dbm_test_read_success | false |
Other | Homebrew | brew | eb9f9f5e36bc033f9b4227e1ca49697b1556d4df.json | language/haskell: use `v1` commands | Library/Homebrew/language/haskell.rb | @@ -16,7 +16,7 @@ def cabal_sandbox(options = {})
saved_home = ENV["HOME"]
ENV["HOME"] = home
- system "cabal", "sandbox", "init"
+ system "cabal", "v1-sandbox", "init"
cabal_sandbox_bin = pwd/".cabal-sandbox/bin"
mkdir_p cabal_sandbox_bin
@@ -25,7 +25,7 @@ def cabal_sandbox(options = {})
ENV.prepend_path "PATH", cabal_sandbox_bin
# avoid updating the cabal package database more than once
- system "cabal", "update" unless (home/".cabal/packages").exist?
+ system "cabal", "v1-update" unless (home/".cabal/packages").exist?
yield
@@ -41,7 +41,7 @@ def cabal_sandbox(options = {})
end
def cabal_sandbox_add_source(*args)
- system "cabal", "sandbox", "add-source", *args
+ system "cabal", "v1-sandbox", "add-source", *args
end
def cabal_install(*args)
@@ -55,11 +55,11 @@ def cabal_install(*args)
# needed value by a formula at this time (February 2016) was 43,478 for
# git-annex, so 100,000 should be enough to avoid most gratuitous
# backjumps build failures.
- system "cabal", "install", "--jobs=#{make_jobs}", "--max-backjumps=100000", *args
+ system "cabal", "v1-install", "--jobs=#{make_jobs}", "--max-backjumps=100000", *args
end
def cabal_configure(flags)
- system "cabal", "configure", flags
+ system "cabal", "v1-configure", flags
end
def cabal_install_tools(*tools) | false |
Other | Homebrew | brew | 25249f0114a8792de803699c704c7e9e9652f934.json | shims/super/cc: detect High Sierra differently.
Don't rely on `RUBY_PLATFORM`'s kernel version as it's the machine that
Ruby was built on (10.5) for portable ruby. | Library/Homebrew/brew.sh | @@ -167,6 +167,7 @@ export HOMEBREW_PROCESSOR
export HOMEBREW_PRODUCT
export HOMEBREW_OS_VERSION
export HOMEBREW_MACOS_VERSION
+export HOMEBREW_MACOS_VERSION_NUMERIC
export HOMEBREW_USER_AGENT
export HOMEBREW_USER_AGENT_CURL
| true |
Other | Homebrew | brew | 25249f0114a8792de803699c704c7e9e9652f934.json | shims/super/cc: detect High Sierra differently.
Don't rely on `RUBY_PLATFORM`'s kernel version as it's the machine that
Ruby was built on (10.5) for portable ruby. | Library/Homebrew/shims/scm/git | @@ -122,12 +122,7 @@ then
xcode_path="$(/usr/bin/xcode-select -print-path 2>/dev/null)"
if [[ -z "$xcode_path" ]]
then
- if [[ -z "$HOMEBREW_MACOS_VERSION" ]]
- then
- HOMEBREW_MACOS_VERSION="$(/usr/bin/sw_vers -productVersion)"
- fi
- printf -v macos_version_numeric "%02d%02d%02d" ${HOMEBREW_MACOS_VERSION//./ }
- if [[ "$macos_version_numeric" -ge "100900" ]]
+ if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -ge "100900" ]]
then
popup_stub=1
fi | true |
Other | Homebrew | brew | 25249f0114a8792de803699c704c7e9e9652f934.json | shims/super/cc: detect High Sierra differently.
Don't rely on `RUBY_PLATFORM`'s kernel version as it's the machine that
Ruby was built on (10.5) for portable ruby. | Library/Homebrew/shims/super/cc | @@ -18,7 +18,7 @@ def mac?
end
def high_sierra_or_later?
- mac? && RUBY_PLATFORM[/darwin\d+/][/\d+/].to_i >= 17
+ mac? && ENV["HOMEBREW_MACOS_VERSION_NUMERIC"].to_s.to_i >= 101300
end
def linux? | true |
Other | Homebrew | brew | 79c2ccd0bc444e0017a61f9fed5777a4d6e7b0eb.json | Generate rubocop_todo.yml for RuboCop RSpec | Library/Homebrew/.rubocop-rspec.yml | @@ -1,6 +0,0 @@
-inherit_from:
- - .rubocop.yml
-
-RSpec/ExpectActual:
- Exclude:
- - 'test/missing_formula_spec.rb' | true |
Other | Homebrew | brew | 79c2ccd0bc444e0017a61f9fed5777a4d6e7b0eb.json | Generate rubocop_todo.yml for RuboCop RSpec | Library/Homebrew/.rubocop.yml | @@ -1,5 +1,6 @@
inherit_from:
- ../.rubocop.yml
+ - .rubocop_todo.yml
AllCops:
Include: | true |
Other | Homebrew | brew | 79c2ccd0bc444e0017a61f9fed5777a4d6e7b0eb.json | Generate rubocop_todo.yml for RuboCop RSpec | Library/Homebrew/.rubocop_todo.yml | @@ -0,0 +1,141 @@
+# This configuration was generated by
+# `rubocop --auto-gen-config`
+# on 2018-09-20 09:03:52 +0100 using RuboCop version 0.59.1.
+# The point is for the user to remove these configuration records
+# one by one as the offenses are removed from the code base.
+# Note that changes in the inspected code, or installation of new
+# versions of RuboCop, may require this file to be generated again.
+
+# Offense count: 1
+# Cop supports --auto-correct.
+Layout/LeadingCommentSpace:
+ Exclude:
+ - 'style.rb'
+
+# Offense count: 27
+RSpec/AnyInstance:
+ Exclude:
+ - 'test/cask/cmd/create_spec.rb'
+ - 'test/cask/cmd/edit_spec.rb'
+ - 'test/cask/cmd/outdated_spec.rb'
+ - 'test/cask/cmd/upgrade_spec.rb'
+ - 'test/caveats_spec.rb'
+ - 'test/cleanup_spec.rb'
+ - 'test/download_strategies_spec.rb'
+ - 'test/formatter_spec.rb'
+ - 'test/os/linux/dependency_collector_spec.rb'
+ - 'test/utils/analytics_spec.rb'
+ - 'test/utils/git_spec.rb'
+
+# Offense count: 139
+# Configuration parameters: Prefixes.
+# Prefixes: when, with, without
+RSpec/ContextWording:
+ Enabled: false
+
+# Offense count: 69
+RSpec/DescribeClass:
+ Enabled: false
+
+# Offense count: 573
+# Configuration parameters: Max.
+RSpec/ExampleLength:
+ Max: 133
+
+# Offense count: 16
+RSpec/ExpectActual:
+ Exclude:
+ - 'spec/routing/**/*'
+ - 'test/missing_formula_spec.rb'
+
+# Offense count: 21
+RSpec/ExpectInHook:
+ Exclude:
+ - 'test/cache_store_spec.rb'
+ - 'test/cask/audit_spec.rb'
+ - 'test/cmd/reinstall_spec.rb'
+ - 'test/download_strategies_spec.rb'
+ - 'test/linkage_cache_store_spec.rb'
+ - 'test/migrator_spec.rb'
+ - 'test/os/mac/java_requirement_spec.rb'
+
+# Offense count: 32
+# Configuration parameters: CustomTransform, IgnoreMethods.
+RSpec/FilePath:
+ Enabled: false
+
+# Offense count: 6
+# Configuration parameters: AssignmentOnly.
+RSpec/InstanceVariable:
+ Exclude:
+ - 'test/download_strategies_spec.rb'
+ - 'test/support/helper/spec/shared_context/integration_test.rb'
+ - 'test/utils/git_spec.rb'
+ - 'test/version_spec.rb'
+
+# Offense count: 113
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: have_received, receive
+RSpec/MessageSpies:
+ Enabled: false
+
+# Offense count: 1
+RSpec/MissingExampleGroupArgument:
+ Exclude:
+ - 'test/cask/depends_on_spec.rb'
+
+# Offense count: 23
+RSpec/MultipleDescribes:
+ Enabled: false
+
+# Offense count: 544
+# Configuration parameters: AggregateFailuresByDefault.
+RSpec/MultipleExpectations:
+ Max: 26
+
+# Offense count: 929
+RSpec/NamedSubject:
+ Enabled: false
+
+# Offense count: 99
+RSpec/NestedGroups:
+ Max: 5
+
+# Offense count: 11
+RSpec/RepeatedDescription:
+ Exclude:
+ - 'test/inreplace_spec.rb'
+ - 'test/migrator_spec.rb'
+ - 'test/rubocops/dependency_order_cop_spec.rb'
+ - 'test/rubocops/lines_cop_spec.rb'
+ - 'test/tab_spec.rb'
+
+# Offense count: 10
+RSpec/RepeatedExample:
+ Exclude:
+ - 'test/compiler_selector_spec.rb'
+ - 'test/utils/shell_spec.rb'
+
+# Offense count: 31
+RSpec/SubjectStub:
+ Exclude:
+ - 'test/cache_store_spec.rb'
+ - 'test/cmd/update-report/reporter_spec.rb'
+ - 'test/download_strategies_spec.rb'
+ - 'test/formula_installer_spec.rb'
+ - 'test/java_requirement_spec.rb'
+ - 'test/language/python_spec.rb'
+ - 'test/os/mac/java_requirement_spec.rb'
+
+# Offense count: 64
+# Configuration parameters: IgnoreSymbolicNames.
+RSpec/VerifiedDoubles:
+ Enabled: false
+
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle.
+# SupportedStyles: empty, nil, both
+Style/EmptyElse:
+ Exclude:
+ - 'style.rb' | true |
Other | Homebrew | brew | a11fe57cd2c6b982288a8f7436e013fc53e8458b.json | cache_store: handle corrupt DBM database.
When the DBM database cannot be read by the current version of Ruby's
DBM library (due to corruption or another incompatibility) it segfaults
or freezes which takes down the entire Homebrew Ruby process.
This isn't desirable so instead perform a shell out with the Homebrew
Ruby to see if it can read the DBM database before we try to use the
information. If this hangs or crashes: silently delete the database and
recreate it. | Library/Homebrew/cache_store.rb | @@ -1,5 +1,6 @@
require "dbm"
require "json"
+require "timeout"
#
# `CacheStoreDatabase` acts as an interface to a persistent storage mechanism
@@ -46,7 +47,7 @@ def close_if_open!
#
# @return [Boolean]
def created?
- File.exist?(cache_path)
+ cache_path.exist?
end
private
@@ -57,6 +58,10 @@ def created?
# https://docs.oracle.com/cd/E17276_01/html/api_reference/C/envopen.html
DATABASE_MODE = 0664
+ # Spend 5 seconds trying to read the DBM file. If it takes longer than this it
+ # has likely hung or segfaulted.
+ DBM_TEST_READ_TIMEOUT = 5
+
# Lazily loaded database in read/write mode. If this method is called, a
# database file with be created in the `HOMEBREW_CACHE` with name
# corresponding to the `@type` instance variable
@@ -66,6 +71,29 @@ def db
# DBM::WRCREAT: Creates the database if it does not already exist
@db ||= begin
HOMEBREW_CACHE.mkpath
+ if created?
+ dbm_test_read_cmd = SystemCommand.new(
+ ENV["HOMEBREW_RUBY_PATH"],
+ args: [
+ "-rdbm",
+ "-e",
+ "DBM.open('#{dbm_file_path}', #{DATABASE_MODE}, DBM::READER).size",
+ ],
+ print_stderr: false,
+ must_succeed: true,
+ )
+ dbm_test_read_success = begin
+ Timeout.timeout(DBM_TEST_READ_TIMEOUT) do
+ dbm_test_read_cmd.run!
+ true
+ end
+ rescue ErrorDuringExecution, Timeout::Error
+ odebug "Failed to read #{dbm_file_path}!"
+ Process.kill(:KILL, dbm_test_read_cmd.pid)
+ false
+ end
+ cache_path.delete unless dbm_test_read_success
+ end
DBM.open(dbm_file_path, DATABASE_MODE, DBM::WRCREAT)
end
end
@@ -83,15 +111,15 @@ def initialize(type)
#
# @return [String]
def dbm_file_path
- File.join(HOMEBREW_CACHE, @type.to_s)
+ "#{HOMEBREW_CACHE}/#{@type}"
end
# The path where the database resides in the `HOMEBREW_CACHE` for the given
# `@type`
#
# @return [String]
def cache_path
- "#{dbm_file_path}.db"
+ Pathname("#{dbm_file_path}.db")
end
end
| true |
Other | Homebrew | brew | a11fe57cd2c6b982288a8f7436e013fc53e8458b.json | cache_store: handle corrupt DBM database.
When the DBM database cannot be read by the current version of Ruby's
DBM library (due to corruption or another incompatibility) it segfaults
or freezes which takes down the entire Homebrew Ruby process.
This isn't desirable so instead perform a shell out with the Homebrew
Ruby to see if it can read the DBM database before we try to use the
information. If this hangs or crashes: silently delete the database and
recreate it. | Library/Homebrew/system_command.rb | @@ -19,6 +19,8 @@ def system_command!(*args)
class SystemCommand
extend Predicable
+ attr_reader :pid
+
def self.run(executable, **options)
new(executable, **options).run!
end
@@ -122,6 +124,7 @@ def each_output_line(&b)
raw_stdin, raw_stdout, raw_stderr, raw_wait_thr =
Open3.popen3(env, [executable, executable], *args, **options)
+ @pid = raw_wait_thr.pid
write_input_to(raw_stdin)
raw_stdin.close_write
@@ -191,6 +194,7 @@ def merged_output
end
def success?
+ return false if @exit_status.nil?
@exit_status.zero?
end
| true |
Other | Homebrew | brew | a11fe57cd2c6b982288a8f7436e013fc53e8458b.json | cache_store: handle corrupt DBM database.
When the DBM database cannot be read by the current version of Ruby's
DBM library (due to corruption or another incompatibility) it segfaults
or freezes which takes down the entire Homebrew Ruby process.
This isn't desirable so instead perform a shell out with the Homebrew
Ruby to see if it can read the DBM database before we try to use the
information. If this hangs or crashes: silently delete the database and
recreate it. | Library/Homebrew/test/cache_store_spec.rb | @@ -118,25 +118,25 @@
end
describe "#created?" do
- let(:cache_path) { "path/to/homebrew/cache/sample.db" }
+ let(:cache_path) { Pathname("path/to/homebrew/cache/sample.db") }
before(:each) do
allow(subject).to receive(:cache_path).and_return(cache_path)
end
- context "`File.exist?(cache_path)` returns `true`" do
+ context "`cache_path.exist?` returns `true`" do
before(:each) do
- allow(File).to receive(:exist?).with(cache_path).and_return(true)
+ allow(cache_path).to receive(:exist?).and_return(true)
end
it "returns `true`" do
expect(subject.created?).to be(true)
end
end
- context "`File.exist?(cache_path)` returns `false`" do
+ context "`cache_path.exist?` returns `false`" do
before(:each) do
- allow(File).to receive(:exist?).with(cache_path).and_return(false)
+ allow(cache_path).to receive(:exist?).and_return(false)
end
it "returns `false`" do | true |
Other | Homebrew | brew | a11fe57cd2c6b982288a8f7436e013fc53e8458b.json | cache_store: handle corrupt DBM database.
When the DBM database cannot be read by the current version of Ruby's
DBM library (due to corruption or another incompatibility) it segfaults
or freezes which takes down the entire Homebrew Ruby process.
This isn't desirable so instead perform a shell out with the Homebrew
Ruby to see if it can read the DBM database before we try to use the
information. If this hangs or crashes: silently delete the database and
recreate it. | Library/Homebrew/utils/ruby.sh | @@ -47,7 +47,7 @@ setup-ruby-path() {
then
odie "Failed to install vendor Ruby."
fi
- rm -rf "$vendor_dir/bundle/ruby" "$HOMEBREW_CACHE/linkage.db"
+ rm -rf "$vendor_dir/bundle/ruby"
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
fi
fi | true |
Other | Homebrew | brew | e5aaf36f7d8dae5978d345763cd479cb5e5c3678.json | Add spec for `FormulaInstaller#audit_installed`. | Library/Homebrew/test/formula_installer_spec.rb | @@ -150,4 +150,15 @@ class #{Formulary.class_s(dep_name)} < Formula
temporary_install(Failball.new)
}.to raise_error(RuntimeError)
end
+
+ describe "#caveats" do
+ subject(:formula_installer) { described_class.new(Testball.new) }
+
+ it "shows audit problems if HOMEBREW_DEVELOPER is set" do
+ ENV["HOMEBREW_DEVELOPER"] = "1"
+ formula_installer.install
+ expect(formula_installer).to receive(:audit_installed).and_call_original
+ formula_installer.caveats
+ end
+ end
end | false |
Other | Homebrew | brew | 7a991985a47cf523e95fce32a49e195b964841a8.json | Run tests with `HOMEBREW_DEVELOPER` unset. | Library/Homebrew/brew.rb | @@ -51,8 +51,10 @@
internal_dev_cmd = require? HOMEBREW_LIBRARY_PATH/"dev-cmd"/cmd
internal_cmd = internal_dev_cmd
if internal_dev_cmd && !ARGV.homebrew_developer?
- system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config",
- "--replace-all", "homebrew.devcmdrun", "true"
+ if (HOMEBREW_REPOSITORY/".git/config").exist?
+ system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config",
+ "--replace-all", "homebrew.devcmdrun", "true"
+ end
ENV["HOMEBREW_DEV_CMD_RUN"] = "1"
end
end | true |
Other | Homebrew | brew | 7a991985a47cf523e95fce32a49e195b964841a8.json | Run tests with `HOMEBREW_DEVELOPER` unset. | Library/Homebrew/dev-cmd/tests.rb | @@ -43,8 +43,8 @@ def tests
ENV.delete("HOMEBREW_TEMP")
ENV.delete("HOMEBREW_NO_GITHUB_API")
ENV.delete("HOMEBREW_NO_EMOJI")
+ ENV.delete("HOMEBREW_DEVELOPER")
ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1"
- ENV["HOMEBREW_DEVELOPER"] = "1"
ENV["HOMEBREW_NO_COMPAT"] = "1" if args.no_compat?
ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if args.generic?
ENV["HOMEBREW_TEST_ONLINE"] = "1" if args.online? | true |
Other | Homebrew | brew | 7a991985a47cf523e95fce32a49e195b964841a8.json | Run tests with `HOMEBREW_DEVELOPER` unset. | Library/Homebrew/test/cmd/uninstall_spec.rb | @@ -42,6 +42,8 @@
describe "::handle_unsatisfied_dependents" do
specify "when developer" do
+ ENV["HOMEBREW_DEVELOPER"] = "1"
+
expect {
described_class.handle_unsatisfied_dependents(opts)
}.to output(/Warning/).to_stderr
@@ -50,25 +52,21 @@
end
specify "when not developer" do
- run_as_not_developer do
- expect {
- described_class.handle_unsatisfied_dependents(opts)
- }.to output(/Error/).to_stderr
+ expect {
+ described_class.handle_unsatisfied_dependents(opts)
+ }.to output(/Error/).to_stderr
- expect(described_class).to have_failed
- end
+ expect(described_class).to have_failed
end
specify "when not developer and --ignore-dependencies is specified" do
ARGV << "--ignore-dependencies"
- run_as_not_developer do
- expect {
- described_class.handle_unsatisfied_dependents(opts)
- }.not_to output.to_stderr
+ expect {
+ described_class.handle_unsatisfied_dependents(opts)
+ }.not_to output.to_stderr
- expect(described_class).not_to have_failed
- end
+ expect(described_class).not_to have_failed
end
end
end | true |
Other | Homebrew | brew | 7a991985a47cf523e95fce32a49e195b964841a8.json | Run tests with `HOMEBREW_DEVELOPER` unset. | Library/Homebrew/test/utils_spec.rb | @@ -118,18 +118,6 @@ def esc(code)
end
end
- describe "#run_as_not_developer" do
- it "temporarily unsets HOMEBREW_DEVELOPER" do
- ENV["HOMEBREW_DEVELOPER"] = "foo"
-
- run_as_not_developer do
- expect(ENV["HOMEBREW_DEVELOPER"]).to be nil
- end
-
- expect(ENV["HOMEBREW_DEVELOPER"]).to eq("foo")
- end
- end
-
describe "#which" do
let(:cmd) { dir/"foo" }
| true |
Other | Homebrew | brew | 7a991985a47cf523e95fce32a49e195b964841a8.json | Run tests with `HOMEBREW_DEVELOPER` unset. | Library/Homebrew/utils.rb | @@ -296,12 +296,6 @@ def with_custom_locale(locale)
end
end
-def run_as_not_developer
- with_env(HOMEBREW_DEVELOPER: nil) do
- yield
- end
-end
-
# Kernel.system but with exceptions
def safe_system(cmd, *args, **options)
return if Homebrew.system(cmd, *args, **options) | true |
Other | Homebrew | brew | 3063b7fadeb60fc0fa8a859eb4ac90c71c5d4bb5.json | update-reset: allow specifying repositories.
This makes it easier to use this in e.g. CI to quickly reset various
repositories to their upstream versions. | Library/Homebrew/cmd/update-reset.sh | @@ -1,10 +1,11 @@
-#: * `update-reset`:
-#: Fetches and resets Homebrew and all tap repositories using `git`(1) to
-#: their latest `origin/master`. Note this will destroy all your uncommitted
-#: or committed changes.
+#: * `update-reset` [<repositories>]:
+#: Fetches and resets Homebrew and all tap repositories (or the specified
+#: `repositories`) using `git`(1) to their latest `origin/master`. Note this
+#: will destroy all your uncommitted or committed changes.
homebrew-update-reset() {
local DIR
+ local -a REPOS=()
for option in "$@"
do
@@ -15,10 +16,7 @@ homebrew-update-reset() {
[[ "$option" = *d* ]] && HOMEBREW_DEBUG=1
;;
*)
- odie <<EOS
-This command updates brew itself, and does not take formula names.
-Use 'brew upgrade <formula>'.
-EOS
+ REPOS+=("$option")
;;
esac
done
@@ -28,7 +26,12 @@ EOS
set -x
fi
- for DIR in "$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/*
+ if [[ -z "$REPOS" ]]
+ then
+ REPOS+=("$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/*)
+ fi
+
+ for DIR in ${REPOS[@]}
do
[[ -d "$DIR/.git" ]] || continue
cd "$DIR" || continue | true |
Other | Homebrew | brew | 3063b7fadeb60fc0fa8a859eb4ac90c71c5d4bb5.json | update-reset: allow specifying repositories.
This makes it easier to use this in e.g. CI to quickly reset various
repositories to their upstream versions. | docs/Manpage.md | @@ -578,10 +578,10 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
If `--force` (or `-f`) is specified then always do a slower, full update check even
if unnecessary.
- * `update-reset`:
- Fetches and resets Homebrew and all tap repositories using `git`(1) to
- their latest `origin/master`. Note this will destroy all your uncommitted
- or committed changes.
+ * `update-reset` [`repositories`]:
+ Fetches and resets Homebrew and all tap repositories (or the specified
+ `repositories`) using `git`(1) to their latest `origin/master`. Note this
+ will destroy all your uncommitted or committed changes.
* `upgrade` [`install-options`] [`--cleanup`] [`--fetch-HEAD`] [`--ignore-pinned`] [`--display-times`] [`formulae`]:
Upgrade outdated, unpinned brews (with existing install options). | true |
Other | Homebrew | brew | 3063b7fadeb60fc0fa8a859eb4ac90c71c5d4bb5.json | update-reset: allow specifying repositories.
This makes it easier to use this in e.g. CI to quickly reset various
repositories to their upstream versions. | manpages/brew.1 | @@ -527,7 +527,7 @@ If \fB\-\-merge\fR is specified then \fBgit merge\fR is used to include updates
If \fB\-\-force\fR (or \fB\-f\fR) is specified then always do a slower, full update check even if unnecessary\.
.
.IP "\(bu" 4
-\fBupdate\-reset\fR: Fetches and resets Homebrew and all tap repositories using \fBgit\fR(1) to their latest \fBorigin/master\fR\. Note this will destroy all your uncommitted or committed changes\.
+\fBupdate\-reset\fR [\fIrepositories\fR]: Fetches and resets Homebrew and all tap repositories (or the specified \fBrepositories\fR) using \fBgit\fR(1) to their latest \fBorigin/master\fR\. Note this will destroy all your uncommitted or committed changes\.
.
.IP "\(bu" 4
\fBupgrade\fR [\fIinstall\-options\fR] [\fB\-\-cleanup\fR] [\fB\-\-fetch\-HEAD\fR] [\fB\-\-ignore\-pinned\fR] [\fB\-\-display\-times\fR] [\fIformulae\fR]: Upgrade outdated, unpinned brews (with existing install options)\. | true |
Other | Homebrew | brew | ead23d1f4c6eb3ba83e3d126d3874609957325bd.json | Use ActiveSupport File.atomic_write
nd delete our own implementation. | Library/Homebrew/extend/pathname.rb | @@ -162,45 +162,13 @@ def append_lines(content, *open_args)
# NOTE always overwrites
def atomic_write(content)
- require "tempfile"
- tf = Tempfile.new(basename.to_s, dirname)
- begin
- tf.binmode
- tf.write(content)
-
- begin
- old_stat = stat
- rescue Errno::ENOENT
- old_stat = default_stat
+ Dir.mktmpdir(".d", dirname) do |tmpdir|
+ File.atomic_write(self, tmpdir) do |file|
+ file.write(content)
end
-
- uid = Process.uid
- gid = Process.groups.delete(old_stat.gid) { Process.gid }
-
- begin
- tf.chown(uid, gid)
- tf.chmod(old_stat.mode)
- rescue Errno::EPERM # rubocop:disable Lint/HandleExceptions
- end
-
- # Close the file before renaming to prevent the error: Device or resource busy
- # Affects primarily NFS.
- tf.close
- File.rename(tf.path, self)
- ensure
- tf.close!
end
end
- def default_stat
- sentinel = parent.join(".brew.#{Process.pid}.#{rand(Time.now.to_i)}")
- sentinel.open("w") {}
- sentinel.stat
- ensure
- sentinel.unlink
- end
- private :default_stat
-
# @private
def cp_path_sub(pattern, replacement)
raise "#{self} does not exist" unless exist? | true |
Other | Homebrew | brew | ead23d1f4c6eb3ba83e3d126d3874609957325bd.json | Use ActiveSupport File.atomic_write
nd delete our own implementation. | Library/Homebrew/global.rb | @@ -132,6 +132,7 @@ def auditing?
require "extend/string"
require "active_support/core_ext/object/blank"
require "active_support/core_ext/hash/deep_merge"
+require "active_support/core_ext/file/atomic"
require "constants"
require "exceptions" | true |
Other | Homebrew | brew | ead23d1f4c6eb3ba83e3d126d3874609957325bd.json | Use ActiveSupport File.atomic_write
nd delete our own implementation. | Library/Homebrew/test/pathname_spec.rb | @@ -105,14 +105,14 @@
it "preserves permissions" do
File.open(file, "w", 0100777) {}
file.atomic_write("CONTENT")
- expect(file.stat.mode).to eq(0100777 & ~File.umask)
+ expect(file.stat.mode.to_s(8)).to eq((0100777 & ~File.umask).to_s(8))
end
it "preserves default permissions" do
file.atomic_write("CONTENT")
- sentinel = file.parent.join("sentinel")
+ sentinel = file.dirname.join("sentinel")
touch sentinel
- expect(file.stat.mode).to eq(sentinel.stat.mode)
+ expect(file.stat.mode.to_s(8)).to eq(sentinel.stat.mode.to_s(8))
end
end
| true |
Other | Homebrew | brew | ead23d1f4c6eb3ba83e3d126d3874609957325bd.json | Use ActiveSupport File.atomic_write
nd delete our own implementation. | Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/file/atomic.rb | @@ -0,0 +1,70 @@
+# frozen_string_literal: true
+
+require "fileutils"
+
+class File
+ # Write to a file atomically. Useful for situations where you don't
+ # want other processes or threads to see half-written files.
+ #
+ # File.atomic_write('important.file') do |file|
+ # file.write('hello')
+ # end
+ #
+ # This method needs to create a temporary file. By default it will create it
+ # in the same directory as the destination file. If you don't like this
+ # behavior you can provide a different directory but it must be on the
+ # same physical filesystem as the file you're trying to write.
+ #
+ # File.atomic_write('/data/something.important', '/data/tmp') do |file|
+ # file.write('hello')
+ # end
+ def self.atomic_write(file_name, temp_dir = dirname(file_name))
+ require "tempfile" unless defined?(Tempfile)
+
+ Tempfile.open(".#{basename(file_name)}", temp_dir) do |temp_file|
+ temp_file.binmode
+ return_val = yield temp_file
+ temp_file.close
+
+ old_stat = if exist?(file_name)
+ # Get original file permissions
+ stat(file_name)
+ elsif temp_dir != dirname(file_name)
+ # If not possible, probe which are the default permissions in the
+ # destination directory.
+ probe_stat_in(dirname(file_name))
+ end
+
+ if old_stat
+ # Set correct permissions on new file
+ begin
+ chown(old_stat.uid, old_stat.gid, temp_file.path)
+ # This operation will affect filesystem ACL's
+ chmod(old_stat.mode, temp_file.path)
+ rescue Errno::EPERM, Errno::EACCES
+ # Changing file ownership failed, moving on.
+ end
+ end
+
+ # Overwrite original file with temp file
+ rename(temp_file.path, file_name)
+ return_val
+ end
+ end
+
+ # Private utility method.
+ def self.probe_stat_in(dir) #:nodoc:
+ basename = [
+ ".permissions_check",
+ Thread.current.object_id,
+ Process.pid,
+ rand(1000000)
+ ].join(".")
+
+ file_name = join(dir, basename)
+ FileUtils.touch(file_name)
+ stat(file_name)
+ ensure
+ FileUtils.rm_f(file_name) if file_name
+ end
+end | true |
Other | Homebrew | brew | 188aca10759f5b1efee03b4c176b6bafcd71357b.json | Remove blank line | Library/Homebrew/test/cmd/commands_spec.rb | @@ -11,7 +11,6 @@
end
it "prints a list without headers with the --quiet flag" do
-
expect { brew "commands", "--quiet" }
.to be_a_success
.and not_to_output.to_stderr | false |
Other | Homebrew | brew | 0c6331878f0a0c33b3f22dbd6cd6ebf1fb9232ae.json | Use ActiveSupport Hash#deep_merge
And delete our own implementation. | Library/Homebrew/dev-cmd/bottle.rb | @@ -412,7 +412,7 @@ def merge
write = args.write?
bottles_hash = ARGV.named.reduce({}) do |hash, json_file|
- deep_merge_hashes hash, JSON.parse(IO.read(json_file))
+ hash.deep_merge(JSON.parse(IO.read(json_file)))
end
bottles_hash.each do |formula_name, bottle_hash| | true |
Other | Homebrew | brew | 0c6331878f0a0c33b3f22dbd6cd6ebf1fb9232ae.json | Use ActiveSupport Hash#deep_merge
And delete our own implementation. | Library/Homebrew/global.rb | @@ -131,6 +131,7 @@ def auditing?
require "extend/predicable"
require "extend/string"
require "active_support/core_ext/object/blank"
+require "active_support/core_ext/hash/deep_merge"
require "constants"
require "exceptions" | true |
Other | Homebrew | brew | 0c6331878f0a0c33b3f22dbd6cd6ebf1fb9232ae.json | Use ActiveSupport Hash#deep_merge
And delete our own implementation. | Library/Homebrew/utils.rb | @@ -5,7 +5,6 @@
require "utils/formatter"
require "utils/git"
require "utils/github"
-require "utils/hash"
require "utils/inreplace"
require "utils/link"
require "utils/popen" | true |
Other | Homebrew | brew | 0c6331878f0a0c33b3f22dbd6cd6ebf1fb9232ae.json | Use ActiveSupport Hash#deep_merge
And delete our own implementation. | Library/Homebrew/utils/hash.rb | @@ -1,10 +0,0 @@
-def deep_merge_hashes(hash1, hash2)
- merger = proc do |_key, v1, v2|
- if v1.is_a?(Hash) && v2.is_a?(Hash)
- v1.merge v2, &merger
- else
- v2
- end
- end
- hash1.merge hash2, &merger
-end | true |
Other | Homebrew | brew | 0c6331878f0a0c33b3f22dbd6cd6ebf1fb9232ae.json | Use ActiveSupport Hash#deep_merge
And delete our own implementation. | Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/core_ext/hash/deep_merge.rb | @@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class Hash
+ # Returns a new hash with +self+ and +other_hash+ merged recursively.
+ #
+ # h1 = { a: true, b: { c: [1, 2, 3] } }
+ # h2 = { a: false, b: { x: [3, 4, 5] } }
+ #
+ # h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
+ #
+ # Like with Hash#merge in the standard library, a block can be provided
+ # to merge values:
+ #
+ # h1 = { a: 100, b: 200, c: { c1: 100 } }
+ # h2 = { b: 250, c: { c1: 200 } }
+ # h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
+ # # => { a: 100, b: 450, c: { c1: 300 } }
+ def deep_merge(other_hash, &block)
+ dup.deep_merge!(other_hash, &block)
+ end
+
+ # Same as +deep_merge+, but modifies +self+.
+ def deep_merge!(other_hash, &block)
+ merge!(other_hash) do |key, this_val, other_val|
+ if this_val.is_a?(Hash) && other_val.is_a?(Hash)
+ this_val.deep_merge(other_val, &block)
+ elsif block_given?
+ block.call(key, this_val, other_val)
+ else
+ other_val
+ end
+ end
+ end
+end | true |
Other | Homebrew | brew | 05b71b80e41bdef370235f7722719e17a6c2078d.json | Update RuboCop to 0.58.2. | Library/Homebrew/constants.rb | @@ -1,5 +1,5 @@
# frozen_string_literal: true
# RuboCop version used for `brew style` and `brew cask style`
-HOMEBREW_RUBOCOP_VERSION = "0.57.2"
-HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.20.0" # has to be updated when RuboCop version changes
+HOMEBREW_RUBOCOP_VERSION = "0.58.2"
+HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.21.0" # has to be updated when RuboCop version changes | true |
Other | Homebrew | brew | 05b71b80e41bdef370235f7722719e17a6c2078d.json | Update RuboCop to 0.58.2. | Library/Homebrew/test/Gemfile.lock | @@ -37,10 +37,10 @@ GEM
rspec-support (3.8.0)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
- rubocop (0.57.2)
+ rubocop (0.58.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
- parser (>= 2.5)
+ parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
@@ -64,8 +64,8 @@ DEPENDENCIES
rspec-its
rspec-retry
rspec-wait
- rubocop (= 0.57.2)
+ rubocop (= 0.58.2)
simplecov
BUNDLED WITH
- 1.16.2
+ 1.16.4 | true |
Other | Homebrew | brew | a4020db526fc8476b4c8606a1f0c6473e1a197c8.json | Add test for brew info --json=v1 | Library/Homebrew/test/cmd/info_spec.rb | @@ -8,6 +8,11 @@
.to output(/testball: stable 0.1/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
+
+ expect { brew "info", "testball", "--json=v1" }
+ .to output(/\{.+testball.+\}/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
end
end
| false |
Other | Homebrew | brew | 193b5aa07ac9e278dfe123d03566c14572321deb.json | Add test for brew commands --quiet | Library/Homebrew/test/cmd/commands_spec.rb | @@ -6,6 +6,12 @@
it "prints a list of all available commands" do
expect { brew "commands" }
.to output(/Built-in commands/).to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+
+ expect { brew "commands", "--quiet" }
+ .to output.to_stdout
+ .and not_to_output.to_stderr
.and be_a_success
end
end | false |
Other | Homebrew | brew | 955214abc0e776a234d9a52f7c287cfa010f9d97.json | Use ActiveSupport Object#blank? and #present? | Library/Homebrew/cask/cmd/doctor.rb | @@ -75,7 +75,7 @@ def check_taps
ohai "Homebrew Cask Taps:"
[default_tap, *alt_taps].each do |tap|
- if tap.path.nil? || tap.path.to_s.empty?
+ if tap.path.blank?
puts none_string
else
puts "#{tap.path} (#{cask_count_for_tap(tap)})" | true |
Other | Homebrew | brew | 955214abc0e776a234d9a52f7c287cfa010f9d97.json | Use ActiveSupport Object#blank? and #present? | Library/Homebrew/dev-cmd/audit.rb | @@ -961,7 +961,7 @@ def audit
def audit_version
if version.nil?
problem "missing version"
- elsif version.to_s.empty?
+ elsif version.blank?
problem "version is set to an empty string"
elsif !version.detected_from_url?
version_text = version | true |
Other | Homebrew | brew | 955214abc0e776a234d9a52f7c287cfa010f9d97.json | Use ActiveSupport Object#blank? and #present? | Library/Homebrew/dev-cmd/bottle.rb | @@ -453,7 +453,7 @@ def merge
tag = tag.to_s.delete ":"
unless tag.empty?
- if !bottle_hash["bottle"]["tags"][tag].to_s.empty?
+ if bottle_hash["bottle"]["tags"][tag].present?
mismatches << "#{key} => #{tag}"
else
bottle.send(key, old_value => tag.to_sym) | true |
Other | Homebrew | brew | 955214abc0e776a234d9a52f7c287cfa010f9d97.json | Use ActiveSupport Object#blank? and #present? | Library/Homebrew/download_strategy.rb | @@ -1109,7 +1109,7 @@ def initialize(url, name, version, **meta)
def source_modified_time
out, = system_command("bzr", args: ["log", "-l", "1", "--timezone=utc", cached_location])
timestamp = out.chomp
- raise "Could not get any timestamps from bzr!" if timestamp.to_s.empty?
+ raise "Could not get any timestamps from bzr!" if timestamp.blank?
Time.parse(timestamp)
end
| true |
Other | Homebrew | brew | 955214abc0e776a234d9a52f7c287cfa010f9d97.json | Use ActiveSupport Object#blank? and #present? | Library/Homebrew/extend/os/linux/diagnostic.rb | @@ -35,7 +35,7 @@ def check_tmpdir_executable
end
def check_xdg_data_dirs
- return if ENV["XDG_DATA_DIRS"].to_s.empty?
+ return if ENV["XDG_DATA_DIRS"].blank?
return if ENV["XDG_DATA_DIRS"].split("/").include?(HOMEBREW_PREFIX/"share")
<<~EOS
Homebrew's share was not found in your XDG_DATA_DIRS but you have | true |
Other | Homebrew | brew | 955214abc0e776a234d9a52f7c287cfa010f9d97.json | Use ActiveSupport Object#blank? and #present? | Library/Homebrew/global.rb | @@ -130,6 +130,7 @@ def auditing?
require "extend/module"
require "extend/predicable"
require "extend/string"
+require "active_support/core_ext/object/blank"
require "constants"
require "exceptions" | true |
Other | Homebrew | brew | 955214abc0e776a234d9a52f7c287cfa010f9d97.json | Use ActiveSupport Object#blank? and #present? | Library/Homebrew/missing_formula.rb | @@ -142,8 +142,7 @@ def deleted_reason(name, silent: false)
hash, short_hash, *commit_message, relative_path =
Utils.popen_read(log_command).gsub("\\n", "\n").lines.map(&:chomp)
- if hash.to_s.empty? || short_hash.to_s.empty? ||
- relative_path.to_s.empty?
+ if hash.blank? || short_hash.blank? || relative_path.blank?
ofail "No previously deleted formula found." unless silent
return
end | true |
Other | Homebrew | brew | a6f25419aaaeb5fae3eb743d961ed7892ae86075.json | Update vendored gems
- backports to 3.11.4
- plist to 3.4.0 | Library/Homebrew/vendor/Gemfile.lock | @@ -1,8 +1,8 @@
GEM
remote: https://rubygems.org/
specs:
- backports (3.8.0)
- plist (3.3.0)
+ backports (3.11.4)
+ plist (3.4.0)
ruby-macho (2.0.0)
PLATFORMS | true |
Other | Homebrew | brew | a6f25419aaaeb5fae3eb743d961ed7892ae86075.json | Update vendored gems
- backports to 3.11.4
- plist to 3.4.0 | Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb | @@ -3,7 +3,7 @@
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
ruby_version = RbConfig::CONFIG["ruby_version"]
path = File.expand_path('..', __FILE__)
-$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/backports-3.8.0/lib"
+$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/backports-3.11.4/lib"
$:.unshift "#{path}/"
-$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.3.0/lib"
+$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.4.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.0.0/lib" | true |
Other | Homebrew | brew | a6f25419aaaeb5fae3eb743d961ed7892ae86075.json | Update vendored gems
- backports to 3.11.4
- plist to 3.4.0 | Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/backports-3.11.4/lib/backports/2.4.0/string/match.rb | @@ -0,0 +1,7 @@
+unless String.method_defined? :match?
+ class String
+ def match?(*args)
+ !match(*args).nil?
+ end
+ end
+end | true |
Other | Homebrew | brew | a6f25419aaaeb5fae3eb743d961ed7892ae86075.json | Update vendored gems
- backports to 3.11.4
- plist to 3.4.0 | Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/backports-3.8.0/lib/backports/2.4.0/string/match.rb | @@ -1,11 +0,0 @@
-unless String.method_defined? :match?
- class String
- def match?(*args)
- # Fiber to avoid setting $~
- f = Fiber.new do
- !match(*args).nil?
- end
- f.resume
- end
- end
-end | true |
Other | Homebrew | brew | a6f25419aaaeb5fae3eb743d961ed7892ae86075.json | Update vendored gems
- backports to 3.11.4
- plist to 3.4.0 | Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.3.0/lib/plist/generator.rb | @@ -1,222 +0,0 @@
-# encoding: utf-8
-
-# = plist
-#
-# Copyright 2006-2010 Ben Bleything and Patrick May
-# Distributed under the MIT License
-#
-
-module Plist; end
-
-# === Create a plist
-# You can dump an object to a plist in one of two ways:
-#
-# * <tt>Plist::Emit.dump(obj)</tt>
-# * <tt>obj.to_plist</tt>
-# * This requires that you mixin the <tt>Plist::Emit</tt> module, which is already done for +Array+ and +Hash+.
-#
-# The following Ruby classes are converted into native plist types:
-# Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
-# * +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the <array> and <dict> containers (respectively).
-# * +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a <data> element.
-# * User classes may implement +to_plist_node+ to dictate how they should be serialized; otherwise the object will be passed to <tt>Marshal.dump</tt> and the result placed in a <data> element.
-#
-# For detailed usage instructions, refer to USAGE[link:files/docs/USAGE.html] and the methods documented below.
-module Plist::Emit
- # Helper method for injecting into classes. Calls <tt>Plist::Emit.dump</tt> with +self+.
- def to_plist(envelope = true)
- return Plist::Emit.dump(self, envelope)
- end
-
- # Helper method for injecting into classes. Calls <tt>Plist::Emit.save_plist</tt> with +self+.
- def save_plist(filename)
- Plist::Emit.save_plist(self, filename)
- end
-
- # The following Ruby classes are converted into native plist types:
- # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time
- #
- # Write us (via RubyForge) if you think another class can be coerced safely into one of the expected plist classes.
- #
- # +IO+ and +StringIO+ objects are encoded and placed in <data> elements; other objects are <tt>Marshal.dump</tt>'ed unless they implement +to_plist_node+.
- #
- # The +envelope+ parameters dictates whether or not the resultant plist fragment is wrapped in the normal XML/plist header and footer. Set it to false if you only want the fragment.
- def self.dump(obj, envelope = true)
- output = plist_node(obj)
-
- output = wrap(output) if envelope
-
- return output
- end
-
- # Writes the serialized object's plist to the specified filename.
- def self.save_plist(obj, filename)
- File.open(filename, 'wb') do |f|
- f.write(obj.to_plist)
- end
- end
-
- private
- def self.plist_node(element)
- output = ''
-
- if element.respond_to? :to_plist_node
- output << element.to_plist_node
- else
- case element
- when Array
- if element.empty?
- output << "<array/>\n"
- else
- output << tag('array') {
- element.collect {|e| plist_node(e)}
- }
- end
- when Hash
- if element.empty?
- output << "<dict/>\n"
- else
- inner_tags = []
-
- element.keys.sort_by{|k| k.to_s }.each do |k|
- v = element[k]
- inner_tags << tag('key', CGI::escapeHTML(k.to_s))
- inner_tags << plist_node(v)
- end
-
- output << tag('dict') {
- inner_tags
- }
- end
- when true, false
- output << "<#{element}/>\n"
- when Time
- output << tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ'))
- when Date # also catches DateTime
- output << tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ'))
- when String, Symbol, Integer, Float
- output << tag(element_type(element), CGI::escapeHTML(element.to_s))
- when IO, StringIO
- element.rewind
- contents = element.read
- # note that apple plists are wrapped at a different length then
- # what ruby's base64 wraps by default.
- # I used #encode64 instead of #b64encode (which allows a length arg)
- # because b64encode is b0rked and ignores the length arg.
- data = "\n"
- Base64::encode64(contents).gsub(/\s+/, '').scan(/.{1,68}/o) { data << $& << "\n" }
- output << tag('data', data)
- else
- output << comment( 'The <data> element below contains a Ruby object which has been serialized with Marshal.dump.' )
- data = "\n"
- Base64::encode64(Marshal.dump(element)).gsub(/\s+/, '').scan(/.{1,68}/o) { data << $& << "\n" }
- output << tag('data', data )
- end
- end
-
- return output
- end
-
- def self.comment(content)
- return "<!-- #{content} -->\n"
- end
-
- def self.tag(type, contents = '', &block)
- out = nil
-
- if block_given?
- out = IndentedString.new
- out << "<#{type}>"
- out.raise_indent
-
- out << block.call
-
- out.lower_indent
- out << "</#{type}>"
- else
- out = "<#{type}>#{contents.to_s}</#{type}>\n"
- end
-
- return out.to_s
- end
-
- def self.wrap(contents)
- output = ''
-
- output << '<?xml version="1.0" encoding="UTF-8"?>' + "\n"
- output << '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' + "\n"
- output << '<plist version="1.0">' + "\n"
-
- output << contents
-
- output << '</plist>' + "\n"
-
- return output
- end
-
- def self.element_type(item)
- case item
- when String, Symbol
- 'string'
-
- when Integer
- 'integer'
-
- when Float
- 'real'
-
- else
- raise "Don't know about this data type... something must be wrong!"
- end
- end
- private
- class IndentedString #:nodoc:
- attr_accessor :indent_string
-
- def initialize(str = "\t")
- @indent_string = str
- @contents = ''
- @indent_level = 0
- end
-
- def to_s
- return @contents
- end
-
- def raise_indent
- @indent_level += 1
- end
-
- def lower_indent
- @indent_level -= 1 if @indent_level > 0
- end
-
- def <<(val)
- if val.is_a? Array
- val.each do |f|
- self << f
- end
- else
- # if it's already indented, don't bother indenting further
- unless val =~ /\A#{@indent_string}/
- indent = @indent_string * @indent_level
-
- @contents << val.gsub(/^/, indent)
- else
- @contents << val
- end
-
- # it already has a newline, don't add another
- @contents << "\n" unless val =~ /\n$/
- end
- end
- end
-end
-
-class Array #:nodoc:
- include Plist::Emit
-end
-
-class Hash #:nodoc:
- include Plist::Emit
-end | true |
Other | Homebrew | brew | a6f25419aaaeb5fae3eb743d961ed7892ae86075.json | Update vendored gems
- backports to 3.11.4
- plist to 3.4.0 | Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.4.0/lib/plist.rb | @@ -16,6 +16,3 @@
require 'plist/generator'
require 'plist/parser'
require 'plist/version'
-
-module Plist
-end | true |
Other | Homebrew | brew | a6f25419aaaeb5fae3eb743d961ed7892ae86075.json | Update vendored gems
- backports to 3.11.4
- plist to 3.4.0 | Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.4.0/lib/plist/generator.rb | @@ -0,0 +1,230 @@
+# encoding: utf-8
+
+# = plist
+#
+# Copyright 2006-2010 Ben Bleything and Patrick May
+# Distributed under the MIT License
+#
+
+module Plist
+ # === Create a plist
+ # You can dump an object to a plist in one of two ways:
+ #
+ # * <tt>Plist::Emit.dump(obj)</tt>
+ # * <tt>obj.to_plist</tt>
+ # * This requires that you mixin the <tt>Plist::Emit</tt> module, which is already done for +Array+ and +Hash+.
+ #
+ # The following Ruby classes are converted into native plist types:
+ # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, true, false
+ # * +Array+ and +Hash+ are both recursive; their elements will be converted into plist nodes inside the <array> and <dict> containers (respectively).
+ # * +IO+ (and its descendants) and +StringIO+ objects are read from and their contents placed in a <data> element.
+ # * User classes may implement +to_plist_node+ to dictate how they should be serialized; otherwise the object will be passed to <tt>Marshal.dump</tt> and the result placed in a <data> element.
+ #
+ # For detailed usage instructions, refer to USAGE[link:files/docs/USAGE.html] and the methods documented below.
+ module Emit
+ DEFAULT_INDENT = "\t"
+
+ # Helper method for injecting into classes. Calls <tt>Plist::Emit.dump</tt> with +self+.
+ def to_plist(envelope = true, options = {})
+ options = { :indent => DEFAULT_INDENT }.merge(options)
+ return Plist::Emit.dump(self, envelope, options)
+ end
+
+ # Helper method for injecting into classes. Calls <tt>Plist::Emit.save_plist</tt> with +self+.
+ def save_plist(filename, options = {})
+ options = { :indent => DEFAULT_INDENT }.merge(options)
+ Plist::Emit.save_plist(self, filename, options)
+ end
+
+ # The following Ruby classes are converted into native plist types:
+ # Array, Bignum, Date, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time
+ #
+ # Write us (via RubyForge) if you think another class can be coerced safely into one of the expected plist classes.
+ #
+ # +IO+ and +StringIO+ objects are encoded and placed in <data> elements; other objects are <tt>Marshal.dump</tt>'ed unless they implement +to_plist_node+.
+ #
+ # The +envelope+ parameters dictates whether or not the resultant plist fragment is wrapped in the normal XML/plist header and footer. Set it to false if you only want the fragment.
+ def self.dump(obj, envelope = true, options = {})
+ options = { :indent => DEFAULT_INDENT }.merge(options)
+ output = plist_node(obj, options)
+
+ output = wrap(output) if envelope
+
+ return output
+ end
+
+ # Writes the serialized object's plist to the specified filename.
+ def self.save_plist(obj, filename, options = {})
+ options = { :indent => DEFAULT_INDENT }.merge(options)
+ File.open(filename, 'wb') do |f|
+ f.write(obj.to_plist(true, options))
+ end
+ end
+
+ private
+ def self.plist_node(element, options = {})
+ options = { :indent => DEFAULT_INDENT }.merge(options)
+ output = ''
+
+ if element.respond_to? :to_plist_node
+ output << element.to_plist_node
+ else
+ case element
+ when Array
+ if element.empty?
+ output << "<array/>\n"
+ else
+ output << tag('array', '', options) {
+ element.collect {|e| plist_node(e, options)}
+ }
+ end
+ when Hash
+ if element.empty?
+ output << "<dict/>\n"
+ else
+ inner_tags = []
+
+ element.keys.sort_by{|k| k.to_s }.each do |k|
+ v = element[k]
+ inner_tags << tag('key', CGI.escapeHTML(k.to_s), options)
+ inner_tags << plist_node(v, options)
+ end
+
+ output << tag('dict', '', options) {
+ inner_tags
+ }
+ end
+ when true, false
+ output << "<#{element}/>\n"
+ when Time
+ output << tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ'), options)
+ when Date # also catches DateTime
+ output << tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ'), options)
+ when String, Symbol, Integer, Float
+ output << tag(element_type(element), CGI.escapeHTML(element.to_s), options)
+ when IO, StringIO
+ element.rewind
+ contents = element.read
+ # note that apple plists are wrapped at a different length then
+ # what ruby's base64 wraps by default.
+ # I used #encode64 instead of #b64encode (which allows a length arg)
+ # because b64encode is b0rked and ignores the length arg.
+ data = "\n"
+ Base64.encode64(contents).gsub(/\s+/, '').scan(/.{1,68}/o) { data << $& << "\n" }
+ output << tag('data', data, options)
+ else
+ output << comment('The <data> element below contains a Ruby object which has been serialized with Marshal.dump.')
+ data = "\n"
+ Base64.encode64(Marshal.dump(element)).gsub(/\s+/, '').scan(/.{1,68}/o) { data << $& << "\n" }
+ output << tag('data', data, options)
+ end
+ end
+
+ return output
+ end
+
+ def self.comment(content)
+ return "<!-- #{content} -->\n"
+ end
+
+ def self.tag(type, contents = '', options = {}, &block)
+ options = { :indent => DEFAULT_INDENT }.merge(options)
+ out = nil
+
+ if block_given?
+ out = IndentedString.new(options[:indent])
+ out << "<#{type}>"
+ out.raise_indent
+
+ out << block.call
+
+ out.lower_indent
+ out << "</#{type}>"
+ else
+ out = "<#{type}>#{contents.to_s}</#{type}>\n"
+ end
+
+ return out.to_s
+ end
+
+ def self.wrap(contents)
+ output = ''
+
+ output << '<?xml version="1.0" encoding="UTF-8"?>' + "\n"
+ output << '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' + "\n"
+ output << '<plist version="1.0">' + "\n"
+
+ output << contents
+
+ output << '</plist>' + "\n"
+
+ return output
+ end
+
+ def self.element_type(item)
+ case item
+ when String, Symbol
+ 'string'
+
+ when Integer
+ 'integer'
+
+ when Float
+ 'real'
+
+ else
+ raise "Don't know about this data type... something must be wrong!"
+ end
+ end
+ private
+ class IndentedString #:nodoc:
+ attr_accessor :indent_string
+
+ def initialize(str = "\t")
+ @indent_string = str
+ @contents = ''
+ @indent_level = 0
+ end
+
+ def to_s
+ return @contents
+ end
+
+ def raise_indent
+ @indent_level += 1
+ end
+
+ def lower_indent
+ @indent_level -= 1 if @indent_level > 0
+ end
+
+ def <<(val)
+ if val.is_a? Array
+ val.each do |f|
+ self << f
+ end
+ else
+ # if it's already indented, don't bother indenting further
+ unless val =~ /\A#{@indent_string}/
+ indent = @indent_string * @indent_level
+
+ @contents << val.gsub(/^/, indent)
+ else
+ @contents << val
+ end
+
+ # it already has a newline, don't add another
+ @contents << "\n" unless val =~ /\n$/
+ end
+ end
+ end
+ end
+end
+
+class Array #:nodoc:
+ include Plist::Emit
+end
+
+class Hash #:nodoc:
+ include Plist::Emit
+end | true |
Other | Homebrew | brew | a6f25419aaaeb5fae3eb743d961ed7892ae86075.json | Update vendored gems
- backports to 3.11.4
- plist to 3.4.0 | Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/plist-3.4.0/lib/plist/parser.rb | @@ -11,41 +11,41 @@
# === Load a plist file
# This is the main point of the library:
#
-# r = Plist::parse_xml( filename_or_xml )
+# r = Plist.parse_xml(filename_or_xml)
module Plist
-# Note that I don't use these two elements much:
-#
-# + Date elements are returned as DateTime objects.
-# + Data elements are implemented as Tempfiles
-#
-# Plist::parse_xml will blow up if it encounters a Date element.
-# If you encounter such an error, or if you have a Date element which
-# can't be parsed into a Time object, please send your plist file to
-# plist@hexane.org so that I can implement the proper support.
- def Plist::parse_xml( filename_or_xml )
+ # Note that I don't use these two elements much:
+ #
+ # + Date elements are returned as DateTime objects.
+ # + Data elements are implemented as Tempfiles
+ #
+ # Plist.parse_xml will blow up if it encounters a Date element.
+ # If you encounter such an error, or if you have a Date element which
+ # can't be parsed into a Time object, please create an issue
+ # attaching your plist file at https://github.com/patsplat/plist/issues
+ # so folks can implement the proper support.
+ def self.parse_xml(filename_or_xml)
listener = Listener.new
- #parser = REXML::Parsers::StreamParser.new(File.new(filename), listener)
+ # parser = REXML::Parsers::StreamParser.new(File.new(filename), listener)
parser = StreamParser.new(filename_or_xml, listener)
parser.parse
listener.result
end
class Listener
- #include REXML::StreamListener
+ # include REXML::StreamListener
attr_accessor :result, :open
def initialize
@result = nil
- @open = Array.new
+ @open = []
end
-
def tag_start(name, attributes)
- @open.push PTag::mappings[name].new
+ @open.push PTag.mappings[name].new
end
- def text( contents )
+ def text(contents)
@open.last.text = contents if @open.last
end
@@ -60,11 +60,11 @@ def tag_end(name)
end
class StreamParser
- def initialize( plist_data_or_file, listener )
+ def initialize(plist_data_or_file, listener)
if plist_data_or_file.respond_to? :read
@xml = plist_data_or_file.read
elsif File.exist? plist_data_or_file
- @xml = File.read( plist_data_or_file )
+ @xml = File.read(plist_data_or_file)
else
@xml = plist_data_or_file
end
@@ -78,15 +78,14 @@ def initialize( plist_data_or_file, listener )
COMMENT_START = /\A<!--/
COMMENT_END = /.*?-->/m
-
def parse
- plist_tags = PTag::mappings.keys.join('|')
+ plist_tags = PTag.mappings.keys.join('|')
start_tag = /<(#{plist_tags})([^>]*)>/i
end_tag = /<\/(#{plist_tags})[^>]*>/i
require 'strscan'
- @scanner = StringScanner.new( @xml )
+ @scanner = StringScanner.new(@xml)
until @scanner.eos?
if @scanner.scan(COMMENT_START)
@scanner.scan(COMMENT_END)
@@ -132,22 +131,21 @@ def parse_encoding_from_xml_declaration(xml_declaration)
end
class PTag
- @@mappings = { }
- def PTag::mappings
- @@mappings
+ def self.mappings
+ @mappings ||= {}
end
- def PTag::inherited( sub_class )
+ def self.inherited(sub_class)
key = sub_class.to_s.downcase
- key.gsub!(/^plist::/, '' )
+ key.gsub!(/^plist::/, '')
key.gsub!(/^p/, '') unless key == "plist"
- @@mappings[key] = sub_class
+ mappings[key] = sub_class
end
attr_accessor :text, :children
def initialize
- @children = Array.new
+ @children = []
end
def to_ruby
@@ -163,7 +161,7 @@ def to_ruby
class PDict < PTag
def to_ruby
- dict = Hash.new
+ dict = {}
key = nil
children.each do |c|
@@ -181,13 +179,13 @@ def to_ruby
class PKey < PTag
def to_ruby
- CGI::unescapeHTML(text || '')
+ CGI.unescapeHTML(text || '')
end
end
class PString < PTag
def to_ruby
- CGI::unescapeHTML(text || '')
+ CGI.unescapeHTML(text || '')
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.