Skip to content

Commit 324e474

Browse files
authored
fix a bug where resoved file looses package name case (#3608)
motivation: fixing dar://52529014 and rdar://52529011 caused a regression in resolved files serialization in which package name lost its original form, causing slight difference between resolved files in 5.4 and 5.5 changes: udpate serialization code to correctly preserve the package original name when constructing the package ref from the mirrors
1 parent 3553e0f commit 324e474

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Sources/PackageGraph/PinsStore.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ extension PinsStore: JSONSerializable {
131131
let pinsWithOriginalLocations = self.pins.map { pin -> Pin in
132132
let url = self.mirrors.originalURL(for: pin.packageRef.location) ?? pin.packageRef.location
133133
let identity = PackageIdentity(url: url) // FIXME: pin store should also encode identity
134-
return Pin(packageRef: .remote(identity: identity, location: url), state: pin.state)
134+
return Pin(packageRef: .init(identity: identity, kind: pin.packageRef.kind, location: url, name: pin.packageRef.name), state: pin.state)
135135
}
136-
137136
return JSON([
138137
"pins": pinsWithOriginalLocations.sorted(by: { $0.packageRef.identity < $1.packageRef.identity }).toJSON(),
139138
])
@@ -170,7 +169,7 @@ extension PinsStore: SimplePersistanceProtocol {
170169
let pinsWithMirroredLocations = pins.map { pin -> Pin in
171170
let url = self.mirrors.effectiveURL(for: pin.packageRef.location)
172171
let identity = PackageIdentity(url: url) // FIXME: pin store should also encode identity
173-
return Pin(packageRef: .remote(identity: identity, location: url), state: pin.state)
172+
return Pin(packageRef: .init(identity: identity, kind: pin.packageRef.kind, location: url, name: pin.packageRef.name), state: pin.state)
174173
}
175174
self.pinsMap = try Dictionary(pinsWithMirroredLocations.map({ ($0.packageRef.identity, $0) }), uniquingKeysWith: { first, _ in throw StringError("duplicated entry for package \"\(first.packageRef.name)\"") })
176175
}

Tests/PackageGraphTests/PackageGraphTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ class PackageGraphTests: XCTestCase {
12761276

12771277
let fs = InMemoryFileSystem(emptyFiles: [])
12781278
let store = try PinsStore(pinsFile: AbsolutePath("/pins"), fileSystem: fs, mirrors: .init())
1279-
XCTAssertThrows(StringError("duplicated entry for package \"yams\""), { try store.restore(from: json) })
1279+
XCTAssertThrows(StringError("duplicated entry for package \"Yams\""), { try store.restore(from: json) })
12801280
}
12811281

12821282
func testTargetDependencies_Pre52() throws {

0 commit comments

Comments
 (0)