Skip to content

Commit b6d4b90

Browse files
committed
fix: handle dot format within rc releases for Python
1 parent a79f27e commit b6d4b90

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

pkg/agentfs/sdk_version_check.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,17 @@ func normalizeVersion(version string) string {
698698
version = version[1:]
699699
}
700700

701-
// Handle prerelease versions: convert various formats to semver
702-
// 1.3.0rc1 -> 1.3.0-rc1, 1.3rc -> 1.3.0-rc, etc.
701+
// First check if we have a version with dot separator (1.0.0.rc2)
702+
// If so, replace the dot with a hyphen to make it semver compliant
703+
if dotIndex := strings.LastIndex(version, "."); dotIndex > 0 {
704+
// Check if what follows the last dot is a prerelease identifier (starts with a letter)
705+
if dotIndex < len(version)-1 && regexp.MustCompile(`^[a-zA-Z]`).MatchString(version[dotIndex+1:]) {
706+
// Convert 1.0.0.rc2 -> 1.0.0-rc2
707+
version = version[:dotIndex] + "-" + version[dotIndex+1:]
708+
}
709+
}
710+
711+
// Handle prerelease versions without separator: 1.3.0rc1 -> 1.3.0-rc1, 1.3rc -> 1.3.0-rc, etc.
703712
prereleasePattern := regexp.MustCompile(`^(\d+(?:\.\d+)*)([a-zA-Z][a-zA-Z0-9]*.*)$`)
704713
if matches := prereleasePattern.FindStringSubmatch(version); matches != nil {
705714
baseVersion := matches[1]

pkg/agentfs/sdk_version_check_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,13 @@ func TestIsVersionSatisfied(t *testing.T) {
217217
{"~1.5.0", "1.0.0", true, false},
218218
{">=1.5.0", "1.0.0", true, false},
219219
{"==1.5.0", "1.0.0", true, false},
220-
{"1.3.0rc1", "1.3.0", true, false}, // prerelease should satisfy same base version
221-
{"1.3rc", "1.3.0", true, false}, // short prerelease should satisfy same base version
222-
{"1.3.0rc1", "1.4.0", false, false}, // prerelease should not satisfy higher version
220+
{"1.3.0rc1", "1.2.0", true, false}, // prerelease should satisfy lower base version
221+
{"1.3.0.rc1", "1.3.0", true, false}, // prerelease should satisfy same base version
222+
{"1.3rc", "1.3.0", true, false}, // short prerelease should satisfy same base version
223+
{"1.3.0rc1", "1.4.0", false, false}, // prerelease should not satisfy higher version
224+
{"1.0.0.rc2", "1.0.0", true, false}, // dot prerelease should satisfy same base version
225+
{"1.3.0.beta1", "1.3.0", true, false}, // dot prerelease should satisfy same base version
226+
{"1.2.0.alpha1", "1.3.0", false, false}, // dot prerelease should not satisfy higher version
223227
{"invalid", "1.0.0", false, true},
224228
{"1.5.0", "invalid", false, true},
225229
}
@@ -265,6 +269,9 @@ func TestNormalizeVersion(t *testing.T) {
265269
{"1.3rc", "1.3.0-rc"},
266270
{"1.3rc1", "1.3.0-rc1"},
267271
{"~=1.3rc", "1.3.0-rc"},
272+
{"1.0.0.rc2", "1.0.0-rc2"},
273+
{"1.3.0.beta1", "1.3.0-beta1"},
274+
{"1.5.2.alpha3", "1.5.2-alpha3"},
268275
}
269276

270277
for _, tt := range tests {
@@ -412,6 +419,12 @@ func TestParsePythonPackageVersion(t *testing.T) {
412419
expectedOutput: "==1.5.0",
413420
expectedFound: true,
414421
},
422+
{
423+
name: "extra with compatible version",
424+
input: "livekit-agents[extra1,extra2]~=1.5.0.rc2",
425+
expectedOutput: "~=1.5.0.rc2",
426+
expectedFound: true,
427+
},
415428
{
416429
name: "Version with no specifier",
417430
input: "livekit-agents",

0 commit comments

Comments
 (0)