Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/analytics: don't fail on invalid version #16257

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ HOMEBREW_VERSION="$("${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" describe --tag
HOMEBREW_USER_AGENT_VERSION="${HOMEBREW_VERSION}"
if [[ -z "${HOMEBREW_VERSION}" ]]
then
HOMEBREW_VERSION=">=2.5.0 (shallow or no git repository)"
HOMEBREW_USER_AGENT_VERSION="2.X.Y"
HOMEBREW_VERSION=">=4.1.0 (shallow or no git repository)"
HOMEBREW_USER_AGENT_VERSION="4.X.Y"
fi

HOMEBREW_CORE_REPOSITORY="${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core"
Expand Down
8 changes: 6 additions & 2 deletions Library/Homebrew/utils/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,12 @@ def default_tags_influx
sig { returns(T::Hash[Symbol, String]) }
def default_fields_influx
@default_fields_influx ||= begin
version = HOMEBREW_VERSION.match(/^[\d.]+/)[0]
version = "#{version}-dev" if HOMEBREW_VERSION.include?("-")
version = if (match_data = HOMEBREW_VERSION.match(/^[\d.]+/))
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.
os_name_and_version = if (os_version = OS_VERSION.presence) && os_version.downcase.match?(/^[a-z]/)
Expand Down