-
Notifications
You must be signed in to change notification settings - Fork 48
Use swift.org API for getting releases and some snapshot toolchains #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a834083
a4a1cee
e8c0553
b6df2dc
b3d8012
6b9fad4
8eb66fd
c95e0e2
3f27d71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ struct ListAvailable: SwiftlyCommand { | |
discussion: """ | ||
|
||
The toolchain selector determines which toolchains to list. If no selector \ | ||
is provided, all available toolchains will be listed: | ||
is provided, all available release toolchains will be listed: | ||
|
||
$ swiftly list-available | ||
|
||
|
@@ -28,9 +28,9 @@ struct ListAvailable: SwiftlyCommand { | |
The installed snapshots for a given devlopment branch can be listed by specifying the branch as the selector: | ||
|
||
$ swiftly list-available main-snapshot | ||
$ swiftly list-available 5.7-snapshot | ||
$ swiftly list-available 6.0-snapshot | ||
|
||
Note that listing available snapshots is currently unsupported. It will be introduced in a future release. | ||
Note that listing available snapshots before 6.0 is unsupported. | ||
""" | ||
)) | ||
var toolchainSelector: String? | ||
|
@@ -45,18 +45,24 @@ struct ListAvailable: SwiftlyCommand { | |
try ToolchainSelector(parsing: input) | ||
} | ||
|
||
if let selector { | ||
guard !selector.isSnapshotSelector() else { | ||
SwiftlyCore.print("Listing available snapshots is not currently supported.") | ||
return | ||
let config = try Config.load() | ||
|
||
let tc: [ToolchainVersion] | ||
|
||
switch selector { | ||
case let .snapshot(branch, _): | ||
if case let .release(major, _) = branch, major < 6 { | ||
throw Error(message: "Listing available snapshots previous to 6.0 is not supported.") | ||
patrickfreed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
let toolchains = try await SwiftlyCore.httpClient.getReleaseToolchains() | ||
.map(ToolchainVersion.stable) | ||
.filter { selector?.matches(toolchain: $0) ?? true } | ||
tc = try await SwiftlyCore.httpClient.getSnapshotToolchains(platform: config.platform, branch: branch).map { ToolchainVersion.snapshot($0) } | ||
case .stable, .latest: | ||
tc = try await SwiftlyCore.httpClient.getReleaseToolchains(platform: config.platform).map { ToolchainVersion.stable($0) } | ||
default: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I've changed this to add explicit stable/latest case, and a default to catch no selector provided. |
||
tc = try await SwiftlyCore.httpClient.getReleaseToolchains(platform: config.platform).map { ToolchainVersion.stable($0) } | ||
} | ||
|
||
let config = try Config.load() | ||
let toolchains = tc.filter { selector?.matches(toolchain: $0) ?? true } | ||
|
||
let installedToolchains = Set(config.listInstalledToolchains(selector: selector)) | ||
let activeToolchain = config.inUse | ||
|
@@ -100,13 +106,6 @@ struct ListAvailable: SwiftlyCommand { | |
for toolchain in toolchains where toolchain.isStableRelease() { | ||
printToolchain(toolchain) | ||
} | ||
|
||
// print("") | ||
// print("Available snapshot toolchains") | ||
// print("-----------------------------") | ||
// for toolchain in toolchains where toolchain.isSnapshot() { | ||
// printToolchain(toolchain) | ||
// } | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed this is because the data isn't available at the moment. Could this change?