Skip to content

Commit 813fd7a

Browse files
authored
Restore unsupported tools-version error (#4302)
We lost this in the 5.4 refactoring of tools-version parsing.
1 parent a6f877f commit 813fd7a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Sources/PackageLoading/ToolsVersionParser.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ public struct ToolsVersionParser {
8585
throw Error.nonUTF8EncodedManifest(path: manifestPath)
8686
}
8787

88-
return try self.parse(utf8String: manifestContentsDecodedWithUTF8)
88+
do {
89+
return try self.parse(utf8String: manifestContentsDecodedWithUTF8)
90+
} catch Error.malformedToolsVersionSpecification(.commentMarker(.isMissing)) {
91+
throw UnsupportedToolsVersion(packageIdentity: .init(path: manifestPath), currentToolsVersion: .current, packageToolsVersion: .v3)
92+
}
8993
}
9094

9195
public static func parse(utf8String: String) throws -> ToolsVersion {
@@ -653,13 +657,8 @@ extension ManifestLoader {
653657
do {
654658
regularManifestToolsVersion = try ToolsVersionParser.parse(manifestPath: regularManifest, fileSystem: fileSystem)
655659
}
656-
catch {
657-
if case ToolsVersionParser.Error.malformedToolsVersionSpecification(.commentMarker(.isMissing)) = error {
658-
regularManifestToolsVersion = .v3
659-
}
660-
else {
661-
throw error
662-
}
660+
catch let error as UnsupportedToolsVersion where error.packageToolsVersion == .v3 {
661+
regularManifestToolsVersion = .v3
663662
}
664663

665664
// Compare the tools version of this manifest with the regular

0 commit comments

Comments
 (0)