Skip to content

Commit 86dff27

Browse files
authored
Support "swift-" prefix when parsing release snapshot selectors (#77)
1 parent d88eac9 commit 86dff27

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Sources/SwiftlyCore/ToolchainVerison.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ struct StableReleaseParser: ToolchainSelectorParser {
324324
}
325325
}
326326

327-
/// Parser for selectors like the following:
327+
/// Parser for selectors like the following (with optional "swift-" prefix):
328328
/// - a.b-snapshot-YYYY-mm-dd
329329
/// - a.b-snapshot
330330
/// - a.b-DEVELOPMENT-SNAPSHOT-YYYY-mm-dd-a
@@ -334,7 +334,7 @@ struct StableReleaseParser: ToolchainSelectorParser {
334334
/// - a.b-SNAPSHOT
335335
struct ReleaseSnapshotParser: ToolchainSelectorParser {
336336
static let regex: Regex<(Substring, Substring, Substring, Substring?)> =
337-
try! Regex("^([0-9]+)\\.([0-9]+)-(?:snapshot|DEVELOPMENT-SNAPSHOT|SNAPSHOT)(?:-([0-9]{4}-[0-9]{2}-[0-9]{2}))?(?:-a)?$")
337+
try! Regex("^(?:swift-)?([0-9]+)\\.([0-9]+)-(?:snapshot|DEVELOPMENT-SNAPSHOT|SNAPSHOT)(?:-([0-9]{4}-[0-9]{2}-[0-9]{2}))?(?:-a)?$")
338338

339339
func parse(_ input: String) throws -> ToolchainSelector? {
340340
guard let match = try Self.regex.wholeMatch(in: input) else {

Tests/SwiftlyTests/ToolchainSelectorTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ final class ToolchainSelectorTests: SwiftlyTests {
4343
"5.7-snapshot",
4444
"5.7-SNAPSHOT",
4545
"5.7-DEVELOPMENT-SNAPSHOT",
46+
"swift-5.7-snapshot",
47+
"swift-5.7-SNAPSHOT",
48+
"swift-5.7-DEVELOPMENT-SNAPSHOT",
4649
]
4750
try runTest(.snapshot(branch: .release(major: 5, minor: 7), date: nil), parses)
4851
}
@@ -53,6 +56,10 @@ final class ToolchainSelectorTests: SwiftlyTests {
5356
"5.7-SNAPSHOT-2023-06-05",
5457
"5.7-DEVELOPMENT-SNAPSHOT-2023-06-05",
5558
"5.7-DEVELOPMENT-SNAPSHOT-2023-06-05-a",
59+
"swift-5.7-snapshot-2023-06-05",
60+
"swift-5.7-SNAPSHOT-2023-06-05",
61+
"swift-5.7-DEVELOPMENT-SNAPSHOT-2023-06-05",
62+
"swift-5.7-DEVELOPMENT-SNAPSHOT-2023-06-05-a",
5663
]
5764
try runTest(.snapshot(branch: .release(major: 5, minor: 7), date: "2023-06-05"), parses)
5865
}

0 commit comments

Comments
 (0)