Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion eng/versioning/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@

# External dependency versions do not have to match semver format and the semver regular expressions
# will partially match and produce some hilarious results.
external_dependency_version_regex = r'(?<=<version>).+?(?=</version>)'
# Match version content inside any XML element, not just <version>.
# This handles custom property tags like <scala-jackson.version>2.18.6</scala-jackson.version>
# that carry {x-version-update} comments but are not wrapped in <version> elements.
# The lookahead (?=</[a-zA-Z]) ensures we don't match content before XML comments (<!-- -->).
external_dependency_version_regex = r'(?<=>)[^<]+(?=</[a-zA-Z])'
Comment on lines +30 to +34
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to restrict this slightly to either matching <version>...</version> exactly or a common pattern we use for <properties>...</properties> version definitions? Such as all version declarations in <properties>...</properties> suffix with .version.

The regex then can be something like (?<=<((?:[\w-.]+\.)?version)>).+?(?=<\/\1>), where we look for an XML tag that is either <version> itself or <something-custom.morestuff.version>. This also changes the logic to use the first capture group to match the closing tag so we don't need to double define the capture group.


# This is the original regular expression for semver. This differs from the
# previous one in that start of line and end of line anchors are left in place.
Expand Down