Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
324988e7
Commit
324988e7
authored
8 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Simplify `brew cask doctor`.
parent
33fa8094
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/cask/lib/hbc/cli/doctor.rb
+20
-92
20 additions, 92 deletions
Library/Homebrew/cask/lib/hbc/cli/doctor.rb
with
20 additions
and
92 deletions
Library/Homebrew/cask/lib/hbc/cli/doctor.rb
+
20
−
92
View file @
324988e7
...
...
@@ -2,23 +2,13 @@ module Hbc
class
CLI
class
Doctor
<
Base
def
self
.
run
ohai
"macOS Release:"
,
render_with_none_as_error
(
MacOS
.
full_version
)
ohai
"Hardware Architecture:"
,
render_with_none_as_error
(
"
#{
Hardware
::
CPU
.
type
}
-
#{
Hardware
::
CPU
.
bits
}
"
)
ohai
"Ruby Version:"
,
render_with_none_as_error
(
"
#{
RUBY_VERSION
}
-p
#{
RUBY_PATCHLEVEL
}
"
)
ohai
"Ruby Path:"
,
render_with_none_as_error
(
RbConfig
.
ruby
)
# TODO: consider removing most Homebrew constants from doctor output
ohai
"Homebrew Version:"
,
render_with_none_as_error
(
homebrew_version
)
ohai
"Homebrew Executable Path:"
,
render_with_none_as_error
(
HOMEBREW_BREW_FILE
)
ohai
"Homebrew Cellar Path:"
,
render_with_none_as_error
(
homebrew_cellar
)
ohai
"Homebrew Repository Path:"
,
render_with_none_as_error
(
HOMEBREW_REPOSITORY
)
ohai
"Homebrew Origin:"
,
render_with_none_as_error
(
homebrew_origin
)
ohai
"Homebrew-Cask Version:"
,
render_with_none_as_error
(
Hbc
.
full_version
)
ohai
"Homebrew-Cask Version:"
,
Hbc
.
full_version
ohai
"Homebrew-Cask Install Location:"
,
render_install_location
ohai
"Homebrew-Cask Staging Location:"
,
render_staging_location
(
Hbc
.
caskroom
)
ohai
"Homebrew-Cask Cached Downloads:"
,
render_cached_downloads
ohai
"Homebrew-Cask
Default Tap Path:"
,
render_tap_paths
(
Hbc
.
default_tap
.
path
)
ohai
"Homebrew-Cask Alternate Cask Taps:"
,
render_tap_paths
(
a
lt_tap
s
)
ohai
"Homebrew-Cask Default Tap Cask Count:"
,
render_with_none_as_error
(
default_cask_count
)
ohai
"Homebrew-Cask
Taps:"
puts
render_taps
(
Hbc
.
defau
lt_tap
)
puts
render_taps
(
*
alt_taps
)
ohai
"Contents of $LOAD_PATH:"
,
render_load_path
(
$LOAD_PATH
)
ohai
"Contents of $RUBYLIB Environment Variable:"
,
render_env_var
(
"RUBYLIB"
)
ohai
"Contents of $RUBYOPT Environment Variable:"
,
render_env_var
(
"RUBYOPT"
)
...
...
@@ -33,69 +23,6 @@ module Hbc
ohai
"Contents of Locale Environment Variables:"
,
render_with_none
(
locale_variables
)
end
def
self
.
alt_taps
Tap
.
select
{
|
t
|
t
.
cask_dir
&&
t
!=
Hbc
.
default_tap
}
.
map
(
&
:path
)
end
def
self
.
default_cask_count
Hbc
.
default_tap
.
cask_files
.
count
rescue
StandardError
"0
#{
error_string
"Error reading
#{
Hbc
.
default_tap
.
path
}
"
}
"
end
def
self
.
homebrew_origin
homebrew_origin
=
notfound_string
begin
Dir
.
chdir
(
HOMEBREW_REPOSITORY
)
do
homebrew_origin
=
SystemCommand
.
run
(
"/usr/bin/git"
,
args:
%w[config --get remote.origin.url]
,
print_stderr:
false
).
stdout
.
strip
end
if
homebrew_origin
!~
/\S/
homebrew_origin
=
"
#{
none_string
}
#{
error_string
}
"
elsif
homebrew_origin
!~
%r{(mxcl|Homebrew)/(home)?brew(
\.
git)?
\Z
}
homebrew_origin
.
concat
"
#{
error_string
"warning: nonstandard origin"
}
"
end
rescue
StandardError
homebrew_origin
=
error_string
"Not Found - Error running git"
end
homebrew_origin
end
def
self
.
homebrew_cellar
homebrew_constants
(
"cellar"
)
end
def
self
.
homebrew_version
homebrew_constants
(
"version"
)
end
def
self
.
homebrew_taps
Tap
::
TAP_DIRECTORY
end
def
self
.
homebrew_constants
(
name
)
@homebrew_constants
||=
{}
return
@homebrew_constants
[
name
]
if
@homebrew_constants
.
key?
(
name
)
@homebrew_constants
[
name
]
=
notfound_string
begin
@homebrew_constants
[
name
]
=
SystemCommand
.
run!
(
HOMEBREW_BREW_FILE
,
args:
[
"--
#{
name
}
"
],
print_stderr:
false
)
.
stdout
.
strip
if
@homebrew_constants
[
name
]
!~
/\S/
@homebrew_constants
[
name
]
=
"
#{
none_string
}
#{
error_string
}
"
end
path
=
Pathname
.
new
(
@homebrew_constants
[
name
])
@homebrew_constants
[
name
]
=
path
if
path
.
exist?
rescue
StandardError
@homebrew_constants
[
name
]
=
error_string
"Not Found - Error running brew"
end
@homebrew_constants
[
name
]
end
def
self
.
locale_variables
ENV
.
keys
.
grep
(
/^(?:LC_\S+|LANG|LANGUAGE)\Z/
).
collect
{
|
v
|
%Q(
#{
v
}
="
#{
ENV
[
v
]
}
")
}.
sort
.
join
(
"
\n
"
)
end
...
...
@@ -108,10 +35,6 @@ module Hbc
/phinze/
end
def
self
.
notfound_string
Formatter
.
error
(
"Not Found - Unknown Error"
)
end
def
self
.
error_string
(
string
=
"Error"
)
Formatter
.
error
(
"(
#{
string
}
)"
)
end
...
...
@@ -121,20 +44,25 @@ module Hbc
none_string
end
def
self
.
render_with_none_as_error
(
string
)
return
string
if
!
string
.
nil?
&&
string
.
respond_to?
(
:to_s
)
&&
!
string
.
to_s
.
empty?
"
#{
none_string
}
#{
error_string
}
"
def
self
.
alt_taps
Tap
.
select
{
|
t
|
t
.
cask_dir
&&
t
!=
Hbc
.
default_tap
}
end
def
self
.
cask_count_for_tap
(
tap
)
count
=
tap
.
cask_files
.
count
"
#{
count
}
#{
count
==
1
?
"cask"
:
"casks"
}
"
rescue
StandardError
"0
#{
error_string
"error reading
#{
tap
.
path
}
"
}
"
end
def
self
.
render_tap_paths
(
paths
)
paths
=
[
paths
]
unless
paths
.
respond_to?
(
:each
)
paths
.
collect
do
|
dir
|
if
dir
.
nil?
||
dir
.
to_s
.
empty?
def
self
.
render_taps
(
*
taps
)
taps
.
collect
do
|
tap
|
if
tap
.
path
.
nil?
||
tap
.
path
.
to_s
.
empty?
none_string
elsif
dir
.
to_s
.
match
(
legacy_tap_pattern
)
dir
.
to_s
.
concat
(
"
#{
error_string
"Warning: legacy tap path"
}
"
)
elsif
tap
.
path
.
to_s
.
match
(
legacy_tap_pattern
)
tap
.
path
.
to_s
.
concat
(
"
#{
error_string
"Warning: legacy tap path"
}
"
)
else
dir
.
to_s
"
#{
tap
.
path
}
(
#{
cask_count_for_tap
(
tap
)
}
)"
end
end
end
...
...
@@ -151,7 +79,7 @@ module Hbc
# where "doctor" is needed is precisely the situation where such
# things are less dependable.
def
self
.
render_install_location
locations
=
Dir
.
glob
(
Pathname
.
new
(
homebrew_cellar
)
.
join
(
"brew-cask"
,
"*"
)).
reverse
locations
=
Dir
.
glob
(
HOMEBREW_CELLAR
.
join
(
"brew-cask"
,
"*"
)).
reverse
if
locations
.
empty?
none_string
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment