Skip to content

Revert "missing pinned version" change for main #6945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Sources/PackageGraph/PubGrub/PubGrubPackageContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,12 @@ internal final class PubGrubPackageContainer {
/// Returns the best available version for a given term.
func getBestAvailableVersion(for term: Term) throws -> Version? {
assert(term.isPositive, "Expected term to be positive")
let versionSet = term.requirement
var versionSet = term.requirement

// Restrict the selection to the pinned version if is allowed by the current requirements.
if let pinnedVersion {
if versionSet.contains(pinnedVersion) {
// Make sure the pinned version is still available
let version = try self.underlying.versionsDescending().first { pinnedVersion == $0 }
if version != nil {
return version
}
versionSet = .exact(pinnedVersion)
}
}

Expand Down
28 changes: 0 additions & 28 deletions Tests/PackageGraphTests/PubgrubTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1460,34 +1460,6 @@ final class PubgrubTests: XCTestCase {
])
}

func testMissingPin() throws {
// This checks that we can drop pins that are no longer available but still keep the ones
// which fit the constraints.
try builder.serve("a", at: v1, with: ["a": ["b": (.versionSet(v1Range), .specific(["b"]))]])
try builder.serve("a", at: v1_1)
try builder.serve("b", at: v1)
try builder.serve("b", at: v1_1)

let dependencies = try builder.create(dependencies: [
"a": (.versionSet(v1Range), .specific(["a"])),
])

// Here c is pinned to v1.1, but it is no longer available, so the resolver should fall back
// to v1.
let pinsStore = try builder.create(pinsStore: [
"a": (.version(v1), .specific(["a"])),
"b": (.version("1.2.0"), .specific(["b"])),
])

let resolver = builder.create(pins: pinsStore.pins)
let result = resolver.solve(constraints: dependencies)

AssertResult(result, [
("a", .version(v1)),
("b", .version(v1_1)),
])
}

func testBranchedBasedPin() throws {
// This test ensures that we get the SHA listed in Package.resolved for branch-based
// dependencies.
Expand Down