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

Add validation for pants_version format #338

Merged
merged 4 commits into from
Jan 5, 2024
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions tools/src/scie_pants/pants_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def determine_find_links(
def determine_tag_version(
ptex: Ptex, pants_version: str, find_links_dir: Path, github_api_bearer_token: str | None = None
) -> ResolveInfo:
# `pants_version` should be in the format `major.minor.micro`, e.g., `2.17.0`.
# Raise an error if it does not follow this format.
if not pants_version.count(".") == 2:
Copy link
Contributor

@huonw huonw Dec 20, 2023

Choose a reason for hiding this comment

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

FYI, a dev release has a format with more .s, so we'll need to refine this somewhat to support them. For instance: https://github.com/pantsbuild/pants/releases/tag/release_2.20.0.dev3

This is part of why I think we should wait until a network request fails, to be resilient to whatever version format the upstream releases choose to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just improved the error message and added a test. Please take a look! Thank you.

fatal(f"Expected a pants version like `major.minor.micro`, but got `{pants_version}`.\n\n")

stable_version = Version(pants_version)
if stable_version >= PANTS_PEX_GITHUB_RELEASE_VERSION:
return ResolveInfo(stable_version, sha_version=None, find_links=None)
Expand Down