brew.sh: fix handling of dirty git repo

We cache the output of `git describe`, but we don't check whether the
cached value is valid.

This fixes that.
This commit is contained in:
Carlo Cabrera 2024-08-25 02:57:35 +08:00
parent 019fc519da
commit 13115fee7d
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -457,7 +457,9 @@ fi
if [[ -n "${GIT_REVISION}" ]]
then
GIT_DESCRIBE_CACHE_FILE="${GIT_DESCRIBE_CACHE}/${GIT_REVISION}"
if [[ -r "${GIT_DESCRIBE_CACHE_FILE}" ]]
# Pass `--` to guard against `git` being confused by a file named `HEAD`.
if "${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" diff-index --quiet --exit-code HEAD -- 2>/dev/null &&
[[ -r "${GIT_DESCRIBE_CACHE_FILE}" ]]
then
GIT_DESCRIBE_CACHE_HOMEBREW_VERSION="$(cat "${GIT_DESCRIBE_CACHE_FILE}")"
if [[ -n "${GIT_DESCRIBE_CACHE_HOMEBREW_VERSION}" && "${GIT_DESCRIBE_CACHE_HOMEBREW_VERSION}" != *"-dirty" ]]