Skip to content

Commit 0e998cb

Browse files
authored
Revert "missing pinned version" change for main (#6945)
There's an unfortunate interaction here with the resolver precomputation / `LocalPackageContainer` which leads to us rejecting versions as "not available" if they don't happen to be the currently checked out version. We need a more hollistic change to resolve this issue which is out of scope for 5.9, so we'll revert this change here. We need to cherry-pick this to main to make the main => 5.10 automerger viable. (cherry picked from commit 87d65e3)
1 parent d0ae2c5 commit 0e998cb

File tree

2 files changed

+2
-34
lines changed

2 files changed

+2
-34
lines changed

Sources/PackageGraph/PubGrub/PubGrubPackageContainer.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,12 @@ internal final class PubGrubPackageContainer {
7676
/// Returns the best available version for a given term.
7777
func getBestAvailableVersion(for term: Term) throws -> Version? {
7878
assert(term.isPositive, "Expected term to be positive")
79-
let versionSet = term.requirement
79+
var versionSet = term.requirement
8080

8181
// Restrict the selection to the pinned version if is allowed by the current requirements.
8282
if let pinnedVersion {
8383
if versionSet.contains(pinnedVersion) {
84-
// Make sure the pinned version is still available
85-
let version = try self.underlying.versionsDescending().first { pinnedVersion == $0 }
86-
if version != nil {
87-
return version
88-
}
84+
versionSet = .exact(pinnedVersion)
8985
}
9086
}
9187

Tests/PackageGraphTests/PubgrubTests.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,34 +1460,6 @@ final class PubgrubTests: XCTestCase {
14601460
])
14611461
}
14621462

1463-
func testMissingPin() throws {
1464-
// This checks that we can drop pins that are no longer available but still keep the ones
1465-
// which fit the constraints.
1466-
try builder.serve("a", at: v1, with: ["a": ["b": (.versionSet(v1Range), .specific(["b"]))]])
1467-
try builder.serve("a", at: v1_1)
1468-
try builder.serve("b", at: v1)
1469-
try builder.serve("b", at: v1_1)
1470-
1471-
let dependencies = try builder.create(dependencies: [
1472-
"a": (.versionSet(v1Range), .specific(["a"])),
1473-
])
1474-
1475-
// Here c is pinned to v1.1, but it is no longer available, so the resolver should fall back
1476-
// to v1.
1477-
let pinsStore = try builder.create(pinsStore: [
1478-
"a": (.version(v1), .specific(["a"])),
1479-
"b": (.version("1.2.0"), .specific(["b"])),
1480-
])
1481-
1482-
let resolver = builder.create(pins: pinsStore.pins)
1483-
let result = resolver.solve(constraints: dependencies)
1484-
1485-
AssertResult(result, [
1486-
("a", .version(v1)),
1487-
("b", .version(v1_1)),
1488-
])
1489-
}
1490-
14911463
func testBranchedBasedPin() throws {
14921464
// This test ensures that we get the SHA listed in Package.resolved for branch-based
14931465
// dependencies.

0 commit comments

Comments
 (0)