Skip to content

Add tb_version to handle_metadata_tags & Make the version input parser more permissive#7258

Closed
denyshon wants to merge 2 commits intomozilla:mainfrom
denyshon:tb-autotag
Closed

Add tb_version to handle_metadata_tags & Make the version input parser more permissive#7258
denyshon wants to merge 2 commits intomozilla:mainfrom
denyshon:tb-autotag

Conversation

@denyshon
Copy link
Copy Markdown
Contributor

@denyshon denyshon commented Feb 17, 2026

Resolves #2810, resolves #2811.

@denyshon denyshon force-pushed the tb-autotag branch 6 times, most recently from cd0bc55 to c5c8d07 Compare February 17, 2026 12:53
Add tb_version to handle_metadata_tags
Make the version input parser more permissive (allow leading/trailing spaces, allow any text after the version number, allow integer version numbers)
Comment thread kitsune/questions/models.py Outdated

# Remove from the version string anything following the version number.
# A version number is a sequence of digits and dots, starting and ending with a digit.
versionMatch = re.match(r'\d(?:[\d.]*\d)?', version)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Several comments here:

  • Use snake case instead of camel case, so version_match.
  • Your regular expression will match multiple periods in a row like ("148..1.01"). You could avoid that with something like r"\d+(?:\.\d+)*" instead.
  • In our current code, although version removes suffixes like a1 and b2, it keeps suffixes like rc1 and rc2. Your version strips the rc* suffixes.
  • As far as I can tell, your version will never match anything in the development releases (firefox_history_development_releases and thunderbird_history_development_releases), since those only contain versions ending in a*, b*, and rc*. The current version can match versions ending in rc*.
  • I think with your version, release candidate versions will fall through to the _has_beta handling, and be labelled as beta.
  • So, I think your version regular expression will have to include rc* suffixes, or maybe just continue using version = re.split("[a-b]", version)[0]?

Comment thread kitsune/questions/models.py Outdated
Comment on lines +299 to +301
development_releases = product_details.firefox_history_development_releases or product_details.thunderbird_history_development_releases
stability_releases = product_details.firefox_history_stability_releases or product_details.thunderbird_history_stability_releases
major_releases = product_details.firefox_history_major_releases or product_details.thunderbird_history_major_releases
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These variables will always contain the Firefox releases, because they're always "truthy".

Comment thread kitsune/questions/models.py Outdated
or version in stability_releases
or version in major_releases
):
tags.append(product_name + " {}".format(version))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's more readable to use f-strings (f"{product_name} {version}") instead (here and the lines below).

Comment thread kitsune/questions/models.py Outdated
versionMatch = re.match(r'\d(?:[\d.]*\d)?', version)
version = versionMatch.group(0) if versionMatch else ""
# If there are no dots, version is an integer, and we need to add ".0" to find matches among major versions.
if '.' not in version:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the version is empty, this will make it .0.

@denyshon
Copy link
Copy Markdown
Contributor Author

denyshon commented Apr 6, 2026

Hi @escattone, thank you for the review! I've addressed your comments in a follow-up commit (keeping it separate for readability).

My only concern is related to "rc" versions. You are right that the current code respects them, and I've updated my regex string to do the same, but... is there any practical reason to do so? From what I can see, every "rc" entry in the development releases has a corresponding normal entry (without "rc") in the stability/major releases, and modern versions don't have "rc" entries at all. If that's no longer needed, we could remove "rc" from the regex and check development_releases only in helper functions (like _has_beta()). That won't make the existing "rc" versions be labeled as beta, since we'll just find them (the part preceding "rc) in stability_releases/major_releases.

Copy link
Copy Markdown
Contributor

@escattone escattone left a comment

Choose a reason for hiding this comment

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

@denyshon Your question about no longer needing to hande rc* led to some research and I realized that I'd like to change some more things. I ended up creating #7443. Could you review that one, and if you like it, we can close this in favor of #7443?

@denyshon
Copy link
Copy Markdown
Contributor Author

Thank you @escattone! Your patch is definitely better, so let's stick to it and close this one

@denyshon denyshon closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When autoassigning version tags, make the input parser more permissive Autoasssign version tags for Thunderbird

2 participants