-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18402 from Homebrew/brew-tap-speedup
Speed up `brew tap` for no arguments
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Does the quickest output of brew tap possible for no arguments. | ||
# HOMEBREW_LIBRARY is set by bin/brew | ||
# shellcheck disable=SC2154 | ||
|
||
normalise_tap_name() { | ||
local directory="$1" | ||
local user | ||
local repository | ||
|
||
user="$(tr '[:upper:]' '[:lower:]' <<<"${directory%%/*}")" | ||
repository="$(tr '[:upper:]' '[:lower:]' <<<"${directory#*/}")" | ||
repository="${repository#@(home|linux)brew-}" | ||
echo "${user}/${repository}" | ||
} | ||
|
||
homebrew-tap() { | ||
local taplib="${HOMEBREW_LIBRARY}/Taps" | ||
( | ||
shopt -s extglob | ||
|
||
for directory in "${taplib}"/*/* | ||
do | ||
[[ -d "${directory}" ]] || continue | ||
normalise_tap_name "${directory#"${taplib}"/}" | ||
done | sort | ||
) | ||
} |