Skip to content

Commit e237516

Browse files
committed
fixup
1 parent 7a4e672 commit e237516

File tree

1 file changed

+19
-44
lines changed

1 file changed

+19
-44
lines changed

Sources/Workspace/Workspace.swift

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,36 +1343,34 @@ extension Workspace {
13431343
}
13441344
}
13451345

1346-
// FIXME
1347-
// load the pin store from disk so we can compare for any changes
1348-
// this is needed as we want to avoid re-writing the resolved files
1349-
// unless absolutely required
1350-
guard let storedPinStore = observabilityScope.trap({ try self.pinsStore.load() }) else {
1351-
return
1352-
}
1353-
1354-
// compare for any differences between the existing state and the stored one
1355-
// subtle changes between versions of SwiftPM could treat URLs differently
1356-
// in which case we dont want to cause unnecessary churn
1346+
// try to load the pin store from disk so we can compare for any changes
1347+
// this is needed as we want to avoid re-writing the resolved files unless absolutely necessary
13571348
var needsUpdate = false
1358-
if dependenciesToPin.count != storedPinStore.pinsMap.count {
1359-
needsUpdate = true
1360-
} else {
1361-
for dependency in dependenciesToPin {
1362-
if let pin = storedPinStore.pinsMap.first(where: { $0.value.packageRef.equalsIncludingLocation(dependency.packageRef) }) {
1363-
if pin.value.state != PinsStore.Pin(dependency)?.state {
1349+
if let storedPinStore = try? self.pinsStore.load() {
1350+
// compare for any differences between the existing state and the stored one
1351+
// subtle changes between versions of SwiftPM could treat URLs differently
1352+
// in which case we don't want to cause unnecessary churn
1353+
if dependenciesToPin.count != storedPinStore.pinsMap.count {
1354+
needsUpdate = true
1355+
} else {
1356+
for dependency in dependenciesToPin {
1357+
if let pin = storedPinStore.pinsMap.first(where: { $0.value.packageRef.equalsIncludingLocation(dependency.packageRef) }) {
1358+
if pin.value.state != PinsStore.Pin(dependency)?.state {
1359+
needsUpdate = true
1360+
break
1361+
}
1362+
} else {
13641363
needsUpdate = true
13651364
break
13661365
}
1367-
} else {
1368-
needsUpdate = true
1369-
break
13701366
}
13711367
}
1368+
} else {
1369+
needsUpdate = true
13721370
}
13731371

13741372
// exist early is there is nothing to do
1375-
guard needsUpdate else {
1373+
if !needsUpdate {
13761374
return
13771375
}
13781376

@@ -1382,29 +1380,6 @@ extension Workspace {
13821380
pinsStore.pin(dependency)
13831381
}
13841382

1385-
/*
1386-
// Reset the pinsStore and start pinning the required dependencies.
1387-
pinsStore.unpinAll()
1388-
1389-
let requiredDependencies = dependencyManifests.computePackages().required.filter({ $0.kind.isPinnable })
1390-
for dependency in requiredDependencies {
1391-
if let managedDependency = self.state.dependencies[comparingLocation: dependency] {
1392-
pinsStore.pin(managedDependency)
1393-
} else {
1394-
observabilityScope.emit(warning: "required dependency \(dependency.identity) (\(dependency.locationString)) was not found in managed dependencies and will not be recorded in resolved file")
1395-
}
1396-
}
1397-
*/
1398-
1399-
1400-
/*
1401-
let requiredDependencies = dependencyManifests.computePackages().required
1402-
for dependency in self.state.dependencies {
1403-
if requiredDependencies.contains(where: { $0.equalsIncludingLocation(dependency.packageRef) }) {
1404-
pinsStore.pin(dependency)
1405-
}
1406-
}*/
1407-
14081383
observabilityScope.trap {
14091384
try pinsStore.saveState(toolsVersion: rootManifestsMinimumToolsVersion)
14101385
}

0 commit comments

Comments
 (0)