Skip to content

Commit 5c0794c

Browse files
committed
deprecate name attribute on package dependencies
motivation: follow on work to the change in 5.5 that _allows_ users to not specify a name on the dependency, this soft-deprecates the ability to do so changes: * emit a deprecation warning when using the name attribute on a dependency (in the manifest) * refactor the depedency::name attribute to "deprecatedName" to reflect the fact it was deprecated and prevert too much downstream logic * cleanup the internal API * cleanup and add tests
1 parent 8dd0202 commit 5c0794c

22 files changed

Lines changed: 593 additions & 619 deletions

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import class Foundation.ProcessInfo
1515

1616

1717
/** SwiftPMDataModel is the subset of SwiftPM product that includes just its data model.
18-
This allowis some clients (such as IDEs) that use SwiftPM's data model but not its build system
18+
This allows some clients (such as IDEs) that use SwiftPM's data model but not its build system
1919
to not have to depend on SwiftDriver, SwiftLLBuild, etc. We should probably have better names here,
2020
though that could break some clients.
2121
*/
@@ -33,7 +33,7 @@ let swiftPMDataModelProduct = (
3333
]
3434
)
3535

36-
/** The `libSwiftPM` set of interfaces to programatically work with Swift
36+
/** The `libSwiftPM` set of interfaces to programmatically work with Swift
3737
packages. `libSwiftPM` includes all of the SwiftPM code except the
3838
command line tools, while `libSwiftPMDataModel` includes only the data model.
3939

Sources/Commands/Describe.swift

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
See http://swift.org/LICENSE.txt for license information
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9-
*/
9+
*/
1010

1111
import TSCBasic
1212
import PackageModel
@@ -58,7 +58,7 @@ fileprivate struct DescribedPackage: Encodable {
5858
self.name = package.manifestName // TODO: rename property to manifestName?
5959
self.path = package.path.pathString
6060
self.toolsVersion = "\(package.manifest.toolsVersion.major).\(package.manifest.toolsVersion.minor)"
61-
+ (package.manifest.toolsVersion.patch == 0 ? "" : ".\(package.manifest.toolsVersion.patch)")
61+
+ (package.manifest.toolsVersion.patch == 0 ? "" : ".\(package.manifest.toolsVersion.patch)")
6262
self.dependencies = package.manifest.dependencies.map { DescribedPackageDependency(from: $0) }
6363
self.defaultLocalization = package.manifest.defaultLocalization
6464
self.platforms = package.manifest.platforms.map { DescribedPlatformRestriction(from: $0) }
@@ -100,24 +100,23 @@ fileprivate struct DescribedPackage: Encodable {
100100

101101
/// Represents a package dependency for the sole purpose of generating a description.
102102
enum DescribedPackageDependency: Encodable {
103-
case fileSystem(name: String?, path: AbsolutePath)
104-
case sourceControl(name: String?, location: String, requirement: PackageDependency.SourceControl.Requirement)
103+
case fileSystem(path: AbsolutePath)
104+
case sourceControl(location: String, requirement: PackageDependency.SourceControl.Requirement)
105105
case registry(identity: PackageIdentity, requirement: PackageDependency.Registry.Requirement)
106106

107107
init(from dependency: PackageDependency) {
108108
switch dependency {
109109
case .fileSystem(let settings):
110-
self = .fileSystem(name: dependency.explicitNameForTargetDependencyResolutionOnly, path: settings.path)
110+
self = .fileSystem(path: settings.path)
111111
case .sourceControl(let settings):
112-
self = .sourceControl(name: dependency.explicitNameForTargetDependencyResolutionOnly, location: settings.location, requirement: settings.requirement)
112+
self = .sourceControl(location: settings.location, requirement: settings.requirement)
113113
case .registry(let settings):
114114
self = .registry(identity: settings.identity, requirement: settings.requirement)
115115
}
116116
}
117117

118118
private enum CodingKeys: CodingKey {
119119
case type
120-
case name
121120
case path
122121
case url
123122
case requirement
@@ -133,20 +132,17 @@ fileprivate struct DescribedPackage: Encodable {
133132
public func encode(to encoder: Encoder) throws {
134133
var container = encoder.container(keyedBy: CodingKeys.self)
135134
switch self {
136-
case .fileSystem(let name, let path):
135+
case .fileSystem(let path):
137136
try container.encode(Kind.fileSystem, forKey: .type)
138-
try container.encode(name, forKey: .name)
139137
try container.encode(path, forKey: .path)
140-
case .sourceControl(let name, let location, let requirement):
138+
case .sourceControl(let location, let requirement):
141139
try container.encode(Kind.sourceControl, forKey: .type)
142-
try container.encode(name, forKey: .name)
143140
try container.encode(location, forKey: .url)
144141
try container.encode(requirement, forKey: .requirement)
145142
case .registry(let identity, let requirement):
146143
try container.encode(Kind.registry, forKey: .type)
147144
try container.encode(identity, forKey: .identity)
148145
try container.encode(requirement, forKey: .requirement)
149-
150146
}
151147
}
152148
}
@@ -287,7 +283,7 @@ public struct PlainTextEncoder {
287283

288284
func unkeyedContainer() -> UnkeyedEncodingContainer {
289285
return PlainTextUnkeyedEncodingContainer(outputStream: outputStream, formattingOptions: formattingOptions, userInfo: userInfo, codingPath: codingPath)
290-
}
286+
}
291287

292288
func singleValueContainer() -> SingleValueEncodingContainer {
293289
return TextSingleValueEncodingContainer(outputStream: outputStream, formattingOptions: formattingOptions, userInfo: userInfo, codingPath: codingPath)

0 commit comments

Comments
 (0)