Skip to content

Commit

Permalink
feat: Added support for a new custom version string format, `"1.2.3-c…
Browse files Browse the repository at this point in the history
…ustom.1234+abcdefghi"` (#376)
  • Loading branch information
nfelt14 authored Feb 4, 2025
1 parent 0af4140 commit ddb378c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Valid subsections within a version are:

Things to be included in the next release go here.

### Added

- Updated the `get_version()` function to support more custom version string formats, e.g. `"1.2.3-custom.1234+abcdefghi"`.

---

## v3.1.0 (2025-01-22)
Expand Down
5 changes: 4 additions & 1 deletion src/tm_devices/helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ def get_version(version_string: str) -> Version:
elif version_string.count("-") == 1 and _VALID_VERSION_REGEX.match(
version_string.split("-")[0]
):
version = Version(version_string.replace("-", "+"))
new_version_string = version_string.replace("-", "+", 1)
if new_version_string.count("+") == 2: # noqa: PLR2004
new_version_string = "-".join(new_version_string.rsplit("+", 1))
version = Version(new_version_string)
else:
output_str = ""
for char in version_parts[-1]:
Expand Down
1 change: 1 addition & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ def test_detect_visa_resource_expression(
("1.2.3-alpha.4", Version("1.2.3.alpha.4")),
("1.2.3-custom.52", Version("1.2.3+custom.52")),
("1.2.3-123custom.52", Version("1.2.3+123custom.52")),
("1.2.3-custom.1234+abcdefghi", Version("1.2.3+custom.1234-abcdefghi")),
],
)
def test_get_version(version_string: str, expected_result: Version) -> None:
Expand Down

0 comments on commit ddb378c

Please sign in to comment.