Skip to content
This repository was archived by the owner on Mar 12, 2019. It is now read-only.

Commit 04bd5eb

Browse files
committed
Merge tag Homebrew/1.9.3 into Linuxbrew/master
See https://github.com/Homebrew/brew/releases/tag/1.9.3
2 parents 6613974 + 6a912c3 commit 04bd5eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+390
-310
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/Library/Homebrew/test/fs_leak_log
1818
/Library/Homebrew/vendor/portable-ruby
1919
/Library/Taps
20+
/Library/PinnedTaps
2021

2122
# Ignore Bundler files
2223
**/.bundle/bin

Library/.rubocop.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ Style/GuardClause:
110110
Style/HashSyntax:
111111
EnforcedStyle: hash_rockets
112112
Exclude:
113-
- '**/cmd/*.rb'
113+
- '**/Guardfile'
114+
- '**/cmd/**/*.rb'
115+
- '**/lib/**/*.rb'
116+
- '**/spec/**/*.rb'
114117

115118
# ruby style guide favorite
116119
Style/StringLiterals:

Library/.rubocop_rspec.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
inherit_from: ./.rubocop.yml
2+
3+
NewFormulaAudit:
4+
Enabled: true
5+
6+
# TODO: try to enable these
7+
RSpec/AnyInstance:
8+
Enabled: false
9+
RSpec/ContextWording:
10+
Enabled: false
11+
RSpec/DescribeClass:
12+
Enabled: false
13+
RSpec/ExampleLength:
14+
Enabled: false
15+
RSpec/MessageSpies:
16+
Enabled: false
17+
18+
# TODO: try to reduce these
19+
RSpec/MultipleExpectations:
20+
Max: 26
21+
RSpec/NestedGroups:
22+
Max: 5

Library/Homebrew/.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
inherit_from: ../.rubocop.yml
1+
inherit_from: ../.rubocop_rspec.yml
22

33
AllCops:
44
Include:

Library/Homebrew/brew.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
raise "Homebrew must be run under Ruby 2.3! You're running #{RUBY_VERSION}."
1111
end
1212

13+
# Also define here so we can rescue regardless of location.
14+
class MissingEnvironmentVariables < RuntimeError; end
15+
1316
begin
1417
require_relative "global"
1518
rescue MissingEnvironmentVariables => e

Library/Homebrew/cleanup.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def prune?(days)
5252

5353
return true if symlink? && !exist?
5454

55-
mtime < days.days.ago
55+
mtime < days.days.ago && ctime < days.days.ago
5656
end
5757

5858
def stale?(scrub = false)
@@ -124,7 +124,10 @@ def stale_cask?(scrub)
124124

125125
return true if scrub && !cask.versions.include?(cask.version)
126126

127-
return mtime < CLEANUP_DEFAULT_DAYS.days.ago if cask.version.latest?
127+
if cask.version.latest?
128+
return mtime < CLEANUP_DEFAULT_DAYS.days.ago &&
129+
ctime < CLEANUP_DEFAULT_DAYS.days.ago
130+
end
128131

129132
false
130133
end

Library/Homebrew/cli_parser.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def switch(*names, description: nil, env: nil, required_for: nil, depends_on: ni
5959

6060
enable_switch(*names) if !env.nil? && !ENV["HOMEBREW_#{env.to_s.upcase}"].nil?
6161
end
62+
alias switch_option switch
6263

6364
def usage_banner(text)
6465
@parser.banner = "#{text}\n"

Library/Homebrew/cmd/analytics.rb

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,35 @@
88
#: * `analytics` `regenerate-uuid`:
99
#: Regenerate UUID used in Homebrew's analytics.
1010

11+
require "cli_parser"
12+
1113
module Homebrew
1214
module_function
1315

16+
def analytics_args
17+
Homebrew::CLI::Parser.new do
18+
usage_banner <<~EOS
19+
`analytics` (`on`|`off`) [`state`] [`regenerate-uuid`]
20+
21+
If `on`|`off` is passed, turn Homebrew's analytics on or off respectively.
22+
23+
If `state` is passed, display anonymous user behaviour analytics state.
24+
Read more at <https://docs.brew.sh/Analytics>.
25+
26+
If `regenerate-uuid` is passed, regenerate UUID used in Homebrew's analytics.
27+
EOS
28+
switch :verbose
29+
switch :debug
30+
end
31+
end
32+
1433
def analytics
34+
analytics_args.parse
1535
config_file = HOMEBREW_REPOSITORY/".git/config"
1636

17-
raise UsageError if ARGV.named.size > 1
37+
raise UsageError if args.remaining.size > 1
1838

19-
case ARGV.named.first
39+
case args.remaining.first
2040
when nil, "state"
2141
analyticsdisabled =
2242
Utils.popen_read("git config --file=#{config_file} --get homebrew.analyticsdisabled").chomp

Library/Homebrew/cmd/cat.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
#: * `cat` <formula>:
22
#: Display the source to <formula>.
33

4+
require "cli_parser"
5+
46
module Homebrew
57
module_function
68

9+
def cat_args
10+
Homebrew::CLI::Parser.new do
11+
usage_banner <<~EOS
12+
`cat` <formula>
13+
14+
Display the source to <formula>.
15+
EOS
16+
end
17+
end
18+
719
def cat
20+
cat_args.parse
821
# do not "fix" this to support multiple arguments, the output would be
922
# unparsable, if the user wants to cat multiple formula they can call
1023
# brew cat multiple times.
1124
formulae = ARGV.formulae
1225
raise FormulaUnspecifiedError if formulae.empty?
13-
raise "`brew cat` doesn't support multiple arguments" if formulae.size > 1
26+
raise "`brew cat` doesn't support multiple arguments" if args.remaining.size > 1
1427

1528
cd HOMEBREW_REPOSITORY
1629
exec "cat", formulae.first.path, *ARGV.options_only

Library/Homebrew/cmd/command.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,28 @@
22
#: Display the path to the file which is used when invoking `brew` <cmd>.
33

44
require "commands"
5+
require "cli_parser"
56

67
module Homebrew
78
module_function
89

10+
def command_args
11+
Homebrew::CLI::Parser.new do
12+
usage_banner <<~EOS
13+
`command` <cmd>
14+
15+
Display the path to the file which is used when invoking `brew` <cmd>.
16+
EOS
17+
switch :verbose
18+
switch :debug
19+
end
20+
end
21+
922
def command
10-
abort "This command requires a command argument" if ARGV.empty?
23+
command_args.parse
24+
abort "This command requires a command argument" if args.remaining.empty?
1125

12-
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(ARGV.first, ARGV.first)
26+
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(args.remaining.first, args.remaining.first)
1327

1428
path = Commands.path(cmd)
1529

Library/Homebrew/cmd/commands.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,36 @@
44
#: If `--quiet` is passed, list only the names of commands without the header.
55
#: With `--include-aliases`, the aliases of internal commands will be included.
66

7+
require "cli_parser"
8+
79
module Homebrew
810
module_function
911

12+
def commands_args
13+
Homebrew::CLI::Parser.new do
14+
usage_banner <<~EOS
15+
`commands` [<options>]
16+
17+
Show a list of built-in and external commands.
18+
EOS
19+
switch "--quiet",
20+
description: "List only the names of commands without the header."
21+
switch "--include-aliases",
22+
depends_on: "--quiet",
23+
description: "Include the aliases of internal commands."
24+
switch :verbose
25+
switch :debug
26+
end
27+
end
28+
1029
def commands
11-
if ARGV.include? "--quiet"
30+
commands_args.parse
31+
32+
if args.quiet?
1233
cmds = internal_commands
1334
cmds += external_commands
1435
cmds += internal_developer_commands
15-
cmds += HOMEBREW_INTERNAL_COMMAND_ALIASES.keys if ARGV.include? "--include-aliases"
36+
cmds += HOMEBREW_INTERNAL_COMMAND_ALIASES.keys if args.include_aliases?
1637
puts Formatter.columns(cmds.sort)
1738
return
1839
end

Library/Homebrew/cmd/config.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,28 @@
44
#: provide it.
55

66
require "system_config"
7+
require "cli_parser"
78

89
module Homebrew
910
module_function
1011

12+
def config_args
13+
Homebrew::CLI::Parser.new do
14+
usage_banner <<~EOS
15+
`config`
16+
17+
Show Homebrew and system configuration useful for debugging. If you file
18+
a bug report, you will likely be asked for this information if you do not
19+
provide it.
20+
EOS
21+
switch :verbose
22+
switch :debug
23+
end
24+
end
25+
1126
def config
27+
config_args.parse
28+
raise UsageError unless args.remaining.empty?
1229
SystemConfig.dump_verbose_config
1330
end
1431
end

Library/Homebrew/cmd/gist-logs.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#: If no logs are found, an error message is presented.
1616

1717
require "formula"
18+
require "install"
1819
require "system_config"
1920
require "stringio"
2021
require "socket"
@@ -134,6 +135,8 @@ def create_issue(repo, title, body)
134135
def gist_logs
135136
raise FormulaUnspecifiedError if ARGV.resolved_formulae.length != 1
136137

138+
Install.perform_preinstall_checks(all_fatal: true)
139+
Install.perform_build_from_source_checks(all_fatal: true)
137140
gistify_logs(ARGV.resolved_formulae.first)
138141
end
139142
end

Library/Homebrew/cmd/info.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ def info_formula(f)
174174
end
175175

176176
if devel = f.devel
177-
s = "devel #{devel.version}"
178-
s += " (bottled)" if devel.bottled?
179-
specs << s
177+
specs << "devel #{devel.version}"
180178
end
181179

182180
specs << "HEAD" if f.head

Library/Homebrew/cmd/sh.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,31 @@
99

1010
require "extend/ENV"
1111
require "formula"
12+
require "cli_parser"
1213

1314
module Homebrew
1415
module_function
1516

17+
def sh_args
18+
Homebrew::CLI::Parser.new do
19+
usage_banner <<~EOS
20+
`sh` [<options>]
21+
22+
Start a Homebrew build environment shell. Uses our years-battle-hardened
23+
Homebrew build logic to help your `./configure && make && make install`
24+
or even your `gem install` succeed. Especially handy if you run Homebrew
25+
in an Xcode-only configuration since it adds tools like `make` to your `PATH`
26+
which otherwise build systems would not find.
27+
EOS
28+
flag "--env=",
29+
description: "Use the standard `PATH` instead of superenv's, when <std> is passed"
30+
switch :verbose
31+
switch :debug
32+
end
33+
end
34+
1635
def sh
36+
sh_args.parse
1737
ENV.activate_extensions!
1838

1939
if superenv?

Library/Homebrew/cmd/switch.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,26 @@
33

44
require "formula"
55
require "keg"
6+
require "cli_parser"
67

78
module Homebrew
89
module_function
910

11+
def switch_args
12+
Homebrew::CLI::Parser.new do
13+
usage_banner <<~EOS
14+
`switch` <formula> <version>
15+
16+
Symlink all of the specific <version> of <formula>'s install to Homebrew prefix.
17+
EOS
18+
switch_option :verbose
19+
switch_option :debug
20+
end
21+
end
22+
1023
def switch
11-
name = ARGV.first
24+
switch_args.parse
25+
name = args.remaining.first
1226

1327
usage = "Usage: brew switch <formula> <version>"
1428

@@ -28,9 +42,9 @@ def switch
2842
.map { |d| Keg.new(d).version }
2943
.sort
3044
.join(", ")
31-
version = ARGV.second
45+
version = args.remaining.second
3246

33-
if !version || ARGV.named.length > 2
47+
if !version || args.remaining.length > 2
3448
onoe usage
3549
puts "#{name} installed versions: #{versions}"
3650
exit 1

Library/Homebrew/cmd/upgrade.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def upgrade_formula(f)
147147

148148
fi = FormulaInstaller.new(f)
149149
fi.options = options
150-
fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.bottle?)
150+
fi.build_bottle = ARGV.build_bottle? || (!f.bottle_defined? && f.build.bottle?)
151151
fi.installed_on_request = !ARGV.named.empty?
152152
fi.link_keg ||= keg_was_linked if keg_had_linked_opt
153153
if tab

0 commit comments

Comments
 (0)