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
6af47815
Commit
6af47815
authored
9 years ago
by
Xu Cheng
Browse files
Options
Downloads
Patches
Plain Diff
search: cache remote tap formulae
Closes Homebrew/homebrew#40775. Signed-off-by:
Xu Cheng
<
xucheng@me.com
>
parent
7a59a3ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/cmd/search.rb
+17
-17
17 additions, 17 deletions
Library/Homebrew/cmd/search.rb
with
17 additions
and
17 deletions
Library/Homebrew/cmd/search.rb
+
17
−
17
View file @
6af47815
...
...
@@ -108,36 +108,36 @@ module Homebrew
return
[]
end
results
=
[]
tree
=
{}
@@remote_tap_formulae
||=
Hash
.
new
do
|
cache
,
key
|
user
,
repo
=
key
.
split
(
"/"
,
2
)
tree
=
{}
GitHub
.
open
"https://api.github.com/repos/
#{
user
}
/homebrew-
#{
repo
}
/git/trees/HEAD?recursive=1"
do
|
json
|
user
=
user
.
downcase
if
user
==
"Homebrew"
# special handling for the Homebrew organization
json
[
"tree"
].
each
do
|
object
|
next
unless
object
[
"type"
]
==
"blob"
GitHub
.
open
"https://api.github.com/repos/
#{
user
}
/homebrew-
#{
repo
}
/git/trees/HEAD?recursive=1"
do
|
json
|
json
[
"tree"
].
each
do
|
object
|
next
unless
object
[
"type"
]
==
"blob"
subtree
,
file
=
File
.
split
(
object
[
"path"
])
subtree
,
file
=
File
.
split
(
object
[
"path"
])
if
File
.
extname
(
file
)
==
".rb"
tree
[
subtree
]
||=
[]
tree
[
subtree
]
<<
file
if
File
.
extname
(
file
)
==
".rb"
tree
[
subtree
]
||=
[]
tree
[
subtree
]
<<
file
end
end
end
end
paths
=
tree
[
"Formula"
]
||
tree
[
"HomebrewFormula"
]
||
tree
[
"Casks"
]
||
tree
[
"."
]
||
[]
paths
.
each
do
|
path
|
name
=
File
.
basename
(
path
,
".rb"
)
results
<<
"
#{
user
}
/
#{
repo
}
/
#{
name
}
"
if
rx
===
name
paths
=
tree
[
"Formula"
]
||
tree
[
"HomebrewFormula"
]
||
tree
[
"Casks"
]
||
tree
[
"."
]
||
[]
cache
[
key
]
=
paths
.
map
{
|
path
|
File
.
basename
(
path
,
".rb"
)
}
end
names
=
@@remote_tap_formulae
[
"
#{
user
}
/
#{
repo
}
"
]
user
=
user
.
downcase
if
user
==
"Homebrew"
# special handling for the Homebrew organization
names
.
select
{
|
name
|
rx
===
name
}.
map
{
|
name
|
"
#{
user
}
/
#{
repo
}
/
#{
name
}
"
}
rescue
GitHub
::
HTTPNotFoundError
=>
e
opoo
"Failed to search tap:
#{
user
}
/
#{
repo
}
. Please run `brew update`"
[]
rescue
GitHub
::
Error
=>
e
SEARCH_ERROR_QUEUE
<<
e
[]
else
results
end
def
search_formulae
rx
...
...
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