Skip to content

Commit 966e0d4

Browse files
committed
[SwiftRefactor] PackageManifest: Remove identity from FileSystem and SourceControl
Both types are identified by their path and location respectively.
1 parent b896109 commit 966e0d4

File tree

4 files changed

+4
-17
lines changed

4 files changed

+4
-17
lines changed

Sources/SwiftRefactor/PackageManifest/AddPackageDependency.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ fileprivate extension PackageDependency {
128128
var identifier: String {
129129
switch self {
130130
case .sourceControl(let info):
131-
return info.identity
131+
return info.location
132132
case .fileSystem(let info):
133-
return info.identity
133+
return info.path
134134
case .registry(let info):
135135
return info.identity
136136
}

Sources/SwiftRefactor/PackageManifest/AddPackageTarget.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ fileprivate extension PackageDependency {
349349
static func swiftSyntax(from version: String) -> PackageDependency {
350350
return .sourceControl(
351351
.init(
352-
identity: "swift-syntax",
353352
location: swiftSyntaxURL,
354353
requirement: .rangeFrom(version)
355354
)

Sources/SwiftRefactor/PackageManifest/PackageDependency.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,15 @@ public enum PackageDependency: Sendable {
2222
case registry(Registry)
2323

2424
public struct FileSystem: Sendable {
25-
public let identity: String
2625
public let nameForTargetDependencyResolutionOnly: String?
2726
public let path: String
2827
}
2928

3029
public struct SourceControl: Sendable {
31-
public let identity: String
3230
public let location: String
3331
public let requirement: Requirement
3432

35-
public init(identity: String, location: String, requirement: Requirement) {
36-
self.identity = identity
33+
public init(location: String, requirement: Requirement) {
3734
self.location = location
3835
self.requirement = requirement
3936
}

Tests/SwiftRefactorTest/ManifestEditTests.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ final class ManifestEditTests: XCTestCase {
2323

2424
static let swiftSystemPackageDependency: PackageDependency = .sourceControl(
2525
.init(
26-
identity: "swift-system",
2726
location: swiftSystemURL,
2827
requirement: .branch("main")
2928
)
@@ -54,7 +53,6 @@ final class ManifestEditTests: XCTestCase {
5453
context: .init(
5554
dependency: .sourceControl(
5655
.init(
57-
identity: "swift-system",
5856
location: Self.swiftSystemURL,
5957
requirement: .branch("main")
6058
)
@@ -88,7 +86,6 @@ final class ManifestEditTests: XCTestCase {
8886
context: .init(
8987
dependency: .sourceControl(
9088
.init(
91-
identity: "swift-system",
9289
location: Self.swiftSystemURL,
9390
requirement: .exact("510.0.0")
9491
)
@@ -120,7 +117,6 @@ final class ManifestEditTests: XCTestCase {
120117
context: .init(
121118
dependency: .sourceControl(
122119
.init(
123-
identity: "swift-system",
124120
location: Self.swiftSystemURL,
125121
requirement: .exact("510.0.0")
126122
)
@@ -154,7 +150,6 @@ final class ManifestEditTests: XCTestCase {
154150
context: .init(
155151
dependency: .sourceControl(
156152
.init(
157-
identity: "swift-system",
158153
location: Self.swiftSystemURL,
159154
requirement: .exact("510.0.0")
160155
)
@@ -179,7 +174,7 @@ final class ManifestEditTests: XCTestCase {
179174
)
180175
) { (error: any Error) in
181176
guard let error = error as? ManifestEditError,
182-
case .existingDependency("swift-system") = error
177+
case .existingDependency("https://github.com/apple/swift-system.git") = error
183178
else {
184179
XCTFail("unexpected error thrown: \(error)")
185180
return
@@ -212,7 +207,6 @@ final class ManifestEditTests: XCTestCase {
212207
context: .init(
213208
dependency: .sourceControl(
214209
.init(
215-
identity: "swift-system",
216210
location: Self.swiftSystemURL,
217211
requirement: .rangeFrom("510.0.0")
218212
)
@@ -241,7 +235,6 @@ final class ManifestEditTests: XCTestCase {
241235
context: .init(
242236
dependency: .sourceControl(
243237
.init(
244-
identity: "swift-system",
245238
location: Self.swiftSystemURL,
246239
requirement: .rangeFrom("510.0.0")
247240
)
@@ -268,7 +261,6 @@ final class ManifestEditTests: XCTestCase {
268261
context: .init(
269262
dependency: .sourceControl(
270263
.init(
271-
identity: "swift-system",
272264
location: Self.swiftSystemURL,
273265
requirement: .rangeFrom("510.0.0")
274266
)
@@ -299,7 +291,6 @@ final class ManifestEditTests: XCTestCase {
299291
context: .init(
300292
dependency: .sourceControl(
301293
.init(
302-
identity: "swift-system",
303294
location: Self.swiftSystemURL,
304295
requirement: .range(lowerBound: "508.0.0", upperBound: "510.0.0")
305296
)

0 commit comments

Comments
 (0)