Skip to content

Commit b896109

Browse files
committed
[SwiftRefactor] PackageManifest: Change source control dependency to always accept a string
This matches `PackageDescription` which explicitly states that all source control dependencies expect a URL.
1 parent 68432ea commit b896109

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

Sources/SwiftRefactor/PackageManifest/AddPackageTarget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ fileprivate extension PackageDependency {
350350
return .sourceControl(
351351
.init(
352352
identity: "swift-syntax",
353-
location: .remote(swiftSyntaxURL),
353+
location: swiftSyntaxURL,
354354
requirement: .rangeFrom(version)
355355
)
356356
)

Sources/SwiftRefactor/PackageManifest/PackageDependency.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public enum PackageDependency: Sendable {
2929

3030
public struct SourceControl: Sendable {
3131
public let identity: String
32-
public let location: Location
32+
public let location: String
3333
public let requirement: Requirement
3434

35-
public init(identity: String, location: Location, requirement: Requirement) {
35+
public init(identity: String, location: String, requirement: Requirement) {
3636
self.identity = identity
3737
self.location = location
3838
self.requirement = requirement
@@ -45,11 +45,6 @@ public enum PackageDependency: Sendable {
4545
case revision(String)
4646
case branch(String)
4747
}
48-
49-
public enum Location: Sendable {
50-
case local(String)
51-
case remote(String)
52-
}
5348
}
5449

5550
public struct Registry: Sendable {
@@ -85,12 +80,7 @@ extension PackageDependency.SourceControl: ManifestSyntaxRepresentable {
8580
func asSyntax() -> ExprSyntax {
8681
// TODO: Not handling identity, nameForTargetDependencyResolutionOnly,
8782
// or productFilter yet.
88-
switch location {
89-
case .local:
90-
fatalError()
91-
case .remote(let url):
92-
return ".package(url: \(literal: url.description), \(requirement.asSyntax()))"
93-
}
83+
".package(url: \(literal: location.description), \(requirement.asSyntax()))"
9484
}
9585
}
9686

Tests/SwiftRefactorTest/ManifestEditTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class ManifestEditTests: XCTestCase {
2424
static let swiftSystemPackageDependency: PackageDependency = .sourceControl(
2525
.init(
2626
identity: "swift-system",
27-
location: .remote(swiftSystemURL),
27+
location: swiftSystemURL,
2828
requirement: .branch("main")
2929
)
3030
)
@@ -55,7 +55,7 @@ final class ManifestEditTests: XCTestCase {
5555
dependency: .sourceControl(
5656
.init(
5757
identity: "swift-system",
58-
location: .remote(Self.swiftSystemURL),
58+
location: Self.swiftSystemURL,
5959
requirement: .branch("main")
6060
)
6161
)
@@ -89,7 +89,7 @@ final class ManifestEditTests: XCTestCase {
8989
dependency: .sourceControl(
9090
.init(
9191
identity: "swift-system",
92-
location: .remote(Self.swiftSystemURL),
92+
location: Self.swiftSystemURL,
9393
requirement: .exact("510.0.0")
9494
)
9595
)
@@ -121,7 +121,7 @@ final class ManifestEditTests: XCTestCase {
121121
dependency: .sourceControl(
122122
.init(
123123
identity: "swift-system",
124-
location: .remote(Self.swiftSystemURL),
124+
location: Self.swiftSystemURL,
125125
requirement: .exact("510.0.0")
126126
)
127127
)
@@ -155,7 +155,7 @@ final class ManifestEditTests: XCTestCase {
155155
dependency: .sourceControl(
156156
.init(
157157
identity: "swift-system",
158-
location: .remote(Self.swiftSystemURL),
158+
location: Self.swiftSystemURL,
159159
requirement: .exact("510.0.0")
160160
)
161161
)
@@ -213,7 +213,7 @@ final class ManifestEditTests: XCTestCase {
213213
dependency: .sourceControl(
214214
.init(
215215
identity: "swift-system",
216-
location: .remote(Self.swiftSystemURL),
216+
location: Self.swiftSystemURL,
217217
requirement: .rangeFrom("510.0.0")
218218
)
219219
)
@@ -242,7 +242,7 @@ final class ManifestEditTests: XCTestCase {
242242
dependency: .sourceControl(
243243
.init(
244244
identity: "swift-system",
245-
location: .remote(Self.swiftSystemURL),
245+
location: Self.swiftSystemURL,
246246
requirement: .rangeFrom("510.0.0")
247247
)
248248
)
@@ -269,7 +269,7 @@ final class ManifestEditTests: XCTestCase {
269269
dependency: .sourceControl(
270270
.init(
271271
identity: "swift-system",
272-
location: .remote(Self.swiftSystemURL),
272+
location: Self.swiftSystemURL,
273273
requirement: .rangeFrom("510.0.0")
274274
)
275275
)
@@ -300,7 +300,7 @@ final class ManifestEditTests: XCTestCase {
300300
dependency: .sourceControl(
301301
.init(
302302
identity: "swift-system",
303-
location: .remote(Self.swiftSystemURL),
303+
location: Self.swiftSystemURL,
304304
requirement: .range(lowerBound: "508.0.0", upperBound: "510.0.0")
305305
)
306306
)

0 commit comments

Comments
 (0)