Skip to content

Commit

Permalink
Fix 5.8 compatibility (#118)
Browse files Browse the repository at this point in the history
* Revert "Ran `swiftformat .` on main. No other changes. (#117)"

This reverts commit 7590bea.

* Relax minimum Swift version requirement to 5.8

We still use Swift 5.8 in our CI as a bootstrap compiler.

* Exclude the Vendor directory from formatting

* Ran `swiftformat .` for new 5.8 lang version and excluding Vendor
  • Loading branch information
kateinoigakukun authored Aug 8, 2024
1 parent 7590bea commit 1a5e7c8
Show file tree
Hide file tree
Showing 20 changed files with 473 additions and 464 deletions.
4 changes: 3 additions & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
# Insert explicit `self` where applicable.
--self insert

--swiftversion 5.9
--exclude Sources/Helpers/Vendor

--swiftversion 5.8
6 changes: 3 additions & 3 deletions Sources/AsyncProcess/FileContentStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ private final class ReadIntoAsyncChannelHandler: ChannelDuplexHandler {
private var shouldRead: Bool {
switch self.state {
case .idle:
true
return true
case .error:
false
return false
case .sending:
false
return false
}
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/AsyncProcess/ProcessExecutor+Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ public struct OutputLoggingSettings: Sendable {
func logMessage(line: String) -> Logger.Message {
switch self.to {
case .logMessage:
"\(line)"
return "\(line)"
case .metadata(logMessage: let message, key: _):
message
return message
}
}

func metadata(stream: ProcessOutputStream, line: String) -> Logger.Metadata {
switch self.to {
case .logMessage:
["stream": "\(stream.description)"]
return ["stream": "\(stream.description)"]
case .metadata(logMessage: _, let key):
[key: "\(line)"]
return [key: "\(line)"]
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/AsyncProcess/ProcessExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public struct ProcessOutputStream: Sendable & Hashable & CustomStringConvertible
public var description: String {
switch self.backing {
case .standardOutput:
"stdout"
return "stdout"
case .standardError:
"stderr"
return "stderr"
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions Sources/GeneratorCLI/GeneratorCLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,12 @@ extension GeneratorCLI {
"deprecated: Please explicity specify the subcommand to run. For example: $ swift-sdk-generator make-linux-sdk"
)
}
let linuxDistributionDefaultVersion = switch self.linuxDistributionName {
let linuxDistributionDefaultVersion: String
switch self.linuxDistributionName {
case .rhel:
"ubi9"
linuxDistributionDefaultVersion = "ubi9"
case .ubuntu:
"22.04"
linuxDistributionDefaultVersion = "22.04"
}
let linuxDistributionVersion = self.linuxDistributionVersion ?? linuxDistributionDefaultVersion
let linuxDistribution = try LinuxDistribution(name: linuxDistributionName, version: linuxDistributionVersion)
Expand Down
6 changes: 3 additions & 3 deletions Sources/GeneratorEngine/Cache/SQLite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ public final class SQLite {
var pathString: String {
switch self {
case let .path(path):
path.string
return path.string
case .memory:
":memory:"
return ":memory:"
case .temporary:
""
return ""
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/GeneratorEngine/FileSystem/FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ enum FileSystemError: Error {
extension Error {
func attach(path: FilePath) -> any Error {
if let error = self as? Errno {
FileSystemError.systemError(path, error)
return FileSystemError.systemError(path, error)
} else {
self
return self
}
}
}
4 changes: 2 additions & 2 deletions Sources/GeneratorEngine/FileSystem/OpenReadableFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public struct OpenReadableFile {
func read() async throws -> ReadableFileStream {
switch self.fileHandle {
case let .local(fileDescriptor):
ReadableFileStream.local(.init(fileDescriptor: fileDescriptor, readChunkSize: self.readChunkSize))
return ReadableFileStream.local(.init(fileDescriptor: fileDescriptor, readChunkSize: self.readChunkSize))
case let .virtual(array):
ReadableFileStream.virtual(.init(bytes: array))
return ReadableFileStream.virtual(.init(bytes: array))
}
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/GeneratorEngine/FileSystem/ReadableFileStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public enum ReadableFileStream: AsyncSequence {
public func next() async throws -> [UInt8]? {
switch self {
case let .local(local):
try await local.next()
return try await local.next()
case let .virtual(virtual):
try await virtual.next()
return try await virtual.next()
}
}
}

public func makeAsyncIterator() -> Iterator {
switch self {
case let .local(local):
.local(local.makeAsyncIterator())
return .local(local.makeAsyncIterator())
case let .virtual(virtual):
.virtual(virtual.makeAsyncIterator())
return .virtual(virtual.makeAsyncIterator())
}
}
}
Expand Down
Loading

0 comments on commit 1a5e7c8

Please sign in to comment.