cmd/--version: repair style
This commit is contained in:
parent
18a230dfd5
commit
d68e1fccbc
@ -2,30 +2,32 @@
|
|||||||
#:
|
#:
|
||||||
#: Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output.
|
#: Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output.
|
||||||
|
|
||||||
|
# HOMEBREW_CORE_REPOSITORY, HOMEBREW_CASK_REPOSITORY, HOMEBREW_VERSION are set by brew.sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
version_string() {
|
version_string() {
|
||||||
local repo="$1"
|
local repo="$1"
|
||||||
if ! [ -d "$repo" ]; then
|
if ! [ -d "${repo}" ]; then
|
||||||
echo "N/A"
|
echo "N/A"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local pretty_revision
|
local pretty_revision
|
||||||
pretty_revision="$(git -C "$repo" rev-parse --short --verify --quiet HEAD)"
|
pretty_revision="$(git -C "${repo}" rev-parse --short --verify --quiet HEAD)"
|
||||||
if [ -z "$pretty_revision" ]; then
|
if [ -z "${pretty_revision}" ]; then
|
||||||
echo "(no Git repository)"
|
echo "(no Git repository)"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local git_last_commit_date
|
local git_last_commit_date
|
||||||
git_last_commit_date=$(git -C "$repo" show -s --format='%cd' --date=short HEAD)
|
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})"
|
echo "(git revision ${pretty_revision}; last commit ${git_last_commit_date})"
|
||||||
}
|
}
|
||||||
|
|
||||||
homebrew-version() {
|
homebrew-version() {
|
||||||
echo "Homebrew $HOMEBREW_VERSION"
|
echo "Homebrew ${HOMEBREW_VERSION}"
|
||||||
echo "Homebrew/homebrew-core $(version_string "$HOMEBREW_CORE_REPOSITORY")"
|
echo "Homebrew/homebrew-core $(version_string "${HOMEBREW_CORE_REPOSITORY}")"
|
||||||
|
|
||||||
if [ -d "$HOMEBREW_CASK_REPOSITORY" ]; then
|
if [ -d "${HOMEBREW_CASK_REPOSITORY}" ]; then
|
||||||
echo "Homebrew/homebrew-cask $(version_string "$HOMEBREW_CASK_REPOSITORY")"
|
echo "Homebrew/homebrew-cask $(version_string "${HOMEBREW_CASK_REPOSITORY}")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user