Merge pull request #16257 from Bo98/analytics-version-fix

utils/analytics: don't fail on invalid version
This commit is contained in:
Mike McQuaid 2023-11-30 11:54:18 +00:00 committed by GitHub
commit 14a59d3884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -485,8 +485,8 @@ HOMEBREW_VERSION="$("${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" describe --tag
HOMEBREW_USER_AGENT_VERSION="${HOMEBREW_VERSION}" HOMEBREW_USER_AGENT_VERSION="${HOMEBREW_VERSION}"
if [[ -z "${HOMEBREW_VERSION}" ]] if [[ -z "${HOMEBREW_VERSION}" ]]
then then
HOMEBREW_VERSION=">=2.5.0 (shallow or no git repository)" HOMEBREW_VERSION=">=4.1.0 (shallow or no git repository)"
HOMEBREW_USER_AGENT_VERSION="2.X.Y" HOMEBREW_USER_AGENT_VERSION="4.X.Y"
fi fi
HOMEBREW_CORE_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" HOMEBREW_CORE_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core"

View File

@ -313,8 +313,12 @@ options: options)
sig { returns(T::Hash[Symbol, String]) } sig { returns(T::Hash[Symbol, String]) }
def default_fields_influx def default_fields_influx
@default_fields_influx ||= begin @default_fields_influx ||= begin
version = HOMEBREW_VERSION.match(/^[\d.]+/)[0] version = if (match_data = HOMEBREW_VERSION.match(/^[\d.]+/))
version = "#{version}-dev" if HOMEBREW_VERSION.include?("-") suffix = "-dev" if HOMEBREW_VERSION.include?("-")
match_data[0] + suffix.to_s
else
">=4.1.22"
end
# Only include OS versions with an actual name. # Only include OS versions with an actual name.
os_name_and_version = if (os_version = OS_VERSION.presence) && os_version.downcase.match?(/^[a-z]/) os_name_and_version = if (os_version = OS_VERSION.presence) && os_version.downcase.match?(/^[a-z]/)