-
Notifications
You must be signed in to change notification settings - Fork 49
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 7 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 |
---|---|---|
|
@@ -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. | ||
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. I assumed this is because the data isn't available at the moment. Could this change? |
||
""" | ||
)) | ||
var toolchainSelector: String? | ||
|
@@ -45,18 +45,22 @@ 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) } | ||
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 | ||
|
@@ -95,18 +99,11 @@ struct ListAvailable: SwiftlyCommand { | |
printToolchain(toolchain) | ||
} | ||
} else { | ||
print("Available release toolchains") | ||
print("Available toolchains") | ||
print("----------------------------") | ||
for toolchain in toolchains where toolchain.isStableRelease() { | ||
for toolchain in toolchains { | ||
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. Good call don't need to separate these two lists 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. The output of 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. This else only gets invoked in the absence of a selector, which defaults to all of the releases, since every snapshot build for every branch would be overwhelming and probably not very useful. I can retain the "release" toolchains label to make it clear that these are only releases, but the where clause shouldn't be necessary here. |
||
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.
should note here that only release toolchains will be listed.