brew.sh: Use shims/scm/git for HOMEBREW_VERSION

Move the use of git to determine HOMEBREW_VERSION below the
definition of the function git.
This commit is contained in:
Shaun Jackman 2017-12-20 16:15:19 -08:00
parent 426c998ff5
commit cf27117c46

View File

@ -19,14 +19,6 @@ case "$*" in
--repository|--repo) echo "$HOMEBREW_REPOSITORY"; exit 0 ;; --repository|--repo) echo "$HOMEBREW_REPOSITORY"; exit 0 ;;
esac esac
HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty --abbrev=7 2>/dev/null)"
HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION"
if [[ -z "$HOMEBREW_VERSION" ]]
then
HOMEBREW_VERSION=">=1.4.0 (shallow or no git repository)"
HOMEBREW_USER_AGENT_VERSION="1.X.Y"
fi
# A depth of 1 means this command was directly invoked by a user. # A depth of 1 means this command was directly invoked by a user.
# Higher depths mean this command was invoked by another Homebrew command. # Higher depths mean this command was invoked by another Homebrew command.
export HOMEBREW_COMMAND_DEPTH=$((HOMEBREW_COMMAND_DEPTH + 1)) export HOMEBREW_COMMAND_DEPTH=$((HOMEBREW_COMMAND_DEPTH + 1))
@ -63,6 +55,14 @@ git() {
"$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" "$@" "$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" "$@"
} }
HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty --abbrev=7 2>/dev/null)"
HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION"
if [[ -z "$HOMEBREW_VERSION" ]]
then
HOMEBREW_VERSION=">=1.4.0 (shallow or no git repository)"
HOMEBREW_USER_AGENT_VERSION="1.X.Y"
fi
if [[ "$HOMEBREW_PREFIX" = "/" || "$HOMEBREW_PREFIX" = "/usr" ]] if [[ "$HOMEBREW_PREFIX" = "/" || "$HOMEBREW_PREFIX" = "/usr" ]]
then then
# it may work, but I only see pain this route and don't want to support it # it may work, but I only see pain this route and don't want to support it