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
f732278c
Commit
f732278c
authored
8 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Fix `search_tap` regex/string matching.
parent
50b635e2
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/cmd/search.rb
+13
-11
13 additions, 11 deletions
Library/Homebrew/cmd/search.rb
with
13 additions
and
11 deletions
Library/Homebrew/cmd/search.rb
+
13
−
11
View file @
f732278c
...
@@ -40,8 +40,8 @@ module Homebrew
...
@@ -40,8 +40,8 @@ module Homebrew
exec_browser
"http://packages.ubuntu.com/search?keywords=
#{
ARGV
.
next
}
&searchon=names&suite=all§ion=all"
exec_browser
"http://packages.ubuntu.com/search?keywords=
#{
ARGV
.
next
}
&searchon=names&suite=all§ion=all"
elsif
ARGV
.
include?
"--desc"
elsif
ARGV
.
include?
"--desc"
query
=
ARGV
.
next
query
=
ARGV
.
next
rx
=
query_regexp
(
query
)
r
ege
x
=
query_regexp
(
query
)
Descriptions
.
search
(
rx
,
:desc
).
print
Descriptions
.
search
(
r
ege
x
,
:desc
).
print
elsif
ARGV
.
first
=~
HOMEBREW_TAP_FORMULA_REGEX
elsif
ARGV
.
first
=~
HOMEBREW_TAP_FORMULA_REGEX
query
=
ARGV
.
first
query
=
ARGV
.
first
user
,
repo
,
name
=
query
.
split
(
"/"
,
3
)
user
,
repo
,
name
=
query
.
split
(
"/"
,
3
)
...
@@ -55,10 +55,10 @@ module Homebrew
...
@@ -55,10 +55,10 @@ module Homebrew
puts_columns
Array
(
result
)
puts_columns
Array
(
result
)
else
else
query
=
ARGV
.
first
query
=
ARGV
.
first
rx
=
query_regexp
(
query
)
r
ege
x
=
query_regexp
(
query
)
local_results
=
search_formulae
(
rx
)
local_results
=
search_formulae
(
r
ege
x
)
puts_columns
(
local_results
)
puts_columns
(
local_results
)
tap_results
=
search_taps
(
rx
)
tap_results
=
search_taps
(
r
ege
x
)
puts_columns
(
tap_results
)
puts_columns
(
tap_results
)
if
$stdout
.
tty?
if
$stdout
.
tty?
...
@@ -112,15 +112,17 @@ module Homebrew
...
@@ -112,15 +112,17 @@ module Homebrew
odie
"
#{
query
}
is not a valid regex"
odie
"
#{
query
}
is not a valid regex"
end
end
def
search_taps
(
r
x
)
def
search_taps
(
r
egex_or_string
)
SEARCHABLE_TAPS
.
map
do
|
user
,
repo
|
SEARCHABLE_TAPS
.
map
do
|
user
,
repo
|
Thread
.
new
{
search_tap
(
user
,
repo
,
r
x
)
}
Thread
.
new
{
search_tap
(
user
,
repo
,
r
egex_or_string
)
}
end
.
inject
([])
do
|
results
,
t
|
end
.
inject
([])
do
|
results
,
t
|
results
.
concat
(
t
.
value
)
results
.
concat
(
t
.
value
)
end
end
end
end
def
search_tap
(
user
,
repo
,
rx
)
def
search_tap
(
user
,
repo
,
regex_or_string
)
regex
=
regex_or_string
.
is_a?
(
String
)
?
/^
#{
Regexp
.
escape
(
regex_or_string
)
}
$/
:
regex_or_string
if
(
HOMEBREW_LIBRARY
/
"Taps/
#{
user
.
downcase
}
/homebrew-
#{
repo
.
downcase
}
"
).
directory?
&&
\
if
(
HOMEBREW_LIBRARY
/
"Taps/
#{
user
.
downcase
}
/homebrew-
#{
repo
.
downcase
}
"
).
directory?
&&
\
user
!=
"Caskroom"
user
!=
"Caskroom"
return
[]
return
[]
...
@@ -150,7 +152,7 @@ module Homebrew
...
@@ -150,7 +152,7 @@ module Homebrew
names
=
remote_tap_formulae
[
"
#{
user
}
/
#{
repo
}
"
]
names
=
remote_tap_formulae
[
"
#{
user
}
/
#{
repo
}
"
]
user
=
user
.
downcase
if
user
==
"Homebrew"
# special handling for the Homebrew organization
user
=
user
.
downcase
if
user
==
"Homebrew"
# special handling for the Homebrew organization
names
.
select
{
|
name
|
name
=~
rx
}.
map
{
|
name
|
"
#{
user
}
/
#{
repo
}
/
#{
name
}
"
}
names
.
select
{
|
name
|
name
=~
r
ege
x
}.
map
{
|
name
|
"
#{
user
}
/
#{
repo
}
/
#{
name
}
"
}
rescue
GitHub
::
HTTPNotFoundError
rescue
GitHub
::
HTTPNotFoundError
opoo
"Failed to search tap:
#{
user
}
/
#{
repo
}
. Please run `brew update`"
opoo
"Failed to search tap:
#{
user
}
/
#{
repo
}
. Please run `brew update`"
[]
[]
...
@@ -159,9 +161,9 @@ module Homebrew
...
@@ -159,9 +161,9 @@ module Homebrew
[]
[]
end
end
def
search_formulae
(
rx
)
def
search_formulae
(
r
ege
x
)
aliases
=
Formula
.
alias_full_names
aliases
=
Formula
.
alias_full_names
results
=
(
Formula
.
full_names
+
aliases
).
grep
(
rx
).
sort
results
=
(
Formula
.
full_names
+
aliases
).
grep
(
r
ege
x
).
sort
results
.
map
do
|
name
|
results
.
map
do
|
name
|
begin
begin
...
...
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