Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions Sources/SwiftlyCore/ToolchainVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,17 @@ struct ReleaseSnapshotParser: ToolchainSelectorParser {
}
}

/// Parser for selectors like the following:
/// Parser for selectors like the following (with optional "swift-" prefix):
/// - main-snapshot-YYYY-mm-dd
/// - main-snapshot
/// - main-SNAPSHOT-YYYY-mm-dd
/// - main-SNAPSHOT
/// - swift-DEVELOPMENT-SNAPSHOT-YYYY-mm-dd-a
Copy link
Member

Choose a reason for hiding this comment

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

question: Since the swift prefix is optional with this change, should the examples with the swift prefix remain here to indicate that these are valid selectors?

Copy link
Member Author

Choose a reason for hiding this comment

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

I made this example style aligned with ReleaseSnapshotParser's comment, but just changed to include them.

/// - swift-DEVELOPMENT-SNAPSHOT-YYYY-mm-dd
/// - swift-DEVELOPMENT-SNAPSHOT
/// - DEVELOPMENT-SNAPSHOT-YYYY-mm-dd-a
/// - DEVELOPMENT-SNAPSHOT-YYYY-mm-dd
/// - DEVELOPMENT-SNAPSHOT
struct MainSnapshotParser: ToolchainSelectorParser {
static let regex: Regex<(Substring, Substring?)> =
try! Regex("^(?:main-snapshot|swift-DEVELOPMENT-SNAPSHOT|main-SNAPSHOT)(?:-([0-9]{4}-[0-9]{2}-[0-9]{2}))?(?:-a)?$")
try! Regex("^(?:swift-)?(?:main-snapshot|DEVELOPMENT-SNAPSHOT|main-SNAPSHOT)(?:-([0-9]{4}-[0-9]{2}-[0-9]{2}))?(?:-a)?$")
Copy link
Member

Choose a reason for hiding this comment

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

question: Does this regex now permit selections like swift-main-snapshot-YYYY-mm-dd-a? Does this make sense as a potential selector?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's intentional. Given that we already accept swift-a.b-snapshot-YYYY-mm-dd, it makes main and release channel selectors more consistent.


func parse(_ input: String) throws -> ToolchainSelector? {
guard let match = try Self.regex.wholeMatch(in: input) else {
Expand Down
1 change: 1 addition & 0 deletions Tests/SwiftlyTests/ToolchainSelectorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ final class ToolchainSelectorTests: SwiftlyTests {
"main-SNAPSHOT-2023-06-05",
"swift-DEVELOPMENT-SNAPSHOT-2023-06-05",
"swift-DEVELOPMENT-SNAPSHOT-2023-06-05-a",
"DEVELOPMENT-SNAPSHOT-2023-06-05-a",
]
try runTest(.snapshot(branch: .main, date: "2023-06-05"), parses)
}
Expand Down