forked from Homebrew/brew
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port `brew --version` to Bash to speed it up. While we're here: - remove (now) unused `Tap` Git methods - use `--quiet` instead of `-q` to be more verbose Benchmarks: ``` $ hyperfine --min-runs=3 --warmup=2 "git checkout origin/master; brew --version" "git checkout speedup_brew_version; brew --version" Benchmark #1: git checkout origin/master; brew --version Time (mean ± σ): 2.083 s ± 0.004 s [User: 396.8 ms, System: 597.2 ms] Range (min … max): 2.080 s … 2.088 s 3 runs Benchmark #2: git checkout speedup_brew_version; brew --version Time (mean ± σ): 847.9 ms ± 35.2 ms [User: 100.0 ms, System: 247.9 ms] Range (min … max): 824.1 ms … 888.3 ms 3 runs Summary 'git checkout speedup_brew_version; brew --version' ran 2.46 ± 0.10 times faster than 'git checkout origin/master; brew --version' ```
- Loading branch information
1 parent
3e69c2b
commit dc1fdc9
Showing
12 changed files
with
56 additions
and
130 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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
#: * `--version`, `-v` | ||
#: | ||
#: Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output. | ||
|
||
version_string() { | ||
local repo="$1" | ||
if ! [ -d "$repo" ]; then | ||
echo "N/A" | ||
return | ||
fi | ||
|
||
local pretty_revision | ||
pretty_revision="$(git -C "$repo" rev-parse --short --verify --quiet HEAD)" | ||
if [ -z "$pretty_revision" ]; then | ||
echo "(no Git repository)" | ||
return | ||
fi | ||
|
||
local git_last_commit_date | ||
git_last_commit_date=$(git -C "$repo" show -s --format='%cd' --date=short HEAD) | ||
echo "(git revision ${pretty_revision}; last commit ${git_last_commit_date})" | ||
} | ||
|
||
homebrew-version() { | ||
echo "Homebrew $HOMEBREW_VERSION" | ||
echo "Homebrew/homebrew-core $(version_string "$HOMEBREW_CORE_REPOSITORY")" | ||
|
||
if [ -d "$HOMEBREW_CASK_REPOSITORY" ]; then | ||
echo "Homebrew/homebrew-cask $(version_string "$HOMEBREW_CASK_REPOSITORY")" | ||
fi | ||
} |
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
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
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
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
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