Skip to content

Commit 7fc4545

Browse files
authored
Merge pull request galaxyproject#13570 from natefoo/tool-version-comparison-fix
Workaround to numeric sorting in the local portion of tool versions if they are galaxy "build" numbers
2 parents aed502d + 5142d27 commit 7fc4545

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

lib/galaxy/tools/__init__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,23 @@ def _view(self):
10971097

10981098
@property
10991099
def version_object(self):
1100-
return parse_version(self.version)
1100+
"""Parse version string, handling special Galaxy version format."""
1101+
GALAXY_VERSION_SUFFIX = "+galaxy"
1102+
version = self.version
1103+
1104+
# Check if version has Galaxy suffix that we need to modify (e.g., "1.0+galaxy123")
1105+
if GALAXY_VERSION_SUFFIX not in version:
1106+
return parse_version(version)
1107+
1108+
base_version, suffix = version.split(GALAXY_VERSION_SUFFIX, 1)
1109+
1110+
# Handle Galaxy versions that need numeric sorting
1111+
if suffix:
1112+
# Per PEP-440 a version like <base_version>+galaxy<suffix> would be sorted lexicographically if not separated by a '.'.
1113+
# Injecting a '.' here will force a numeric sort if the suffix is an integer, otherwise the outcome will be the same.
1114+
version = f"{base_version}{GALAXY_VERSION_SUFFIX}.{suffix.lstrip('.')}"
1115+
1116+
return parse_version(version)
11011117

11021118
@property
11031119
def sa_session(self):

0 commit comments

Comments
 (0)