Skip to content

Commit d2114f2

Browse files
committed
[Workspace] Add an option to force resolution
This will force the resolution even if the current checkout has everything that is required. This can be used to "refresh" the managed dependencies contents. <rdar://problem/51463965>
1 parent beddc37 commit d2114f2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Sources/Workspace/Workspace.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ extension Workspace {
489489
container: dependency.packageRef, requirement: requirement)
490490

491491
// Run the resolution.
492-
_resolve(root: root, extraConstraints: [constraint], diagnostics: diagnostics)
492+
_resolve(root: root, forceResolution: false, extraConstraints: [constraint], diagnostics: diagnostics)
493493
}
494494

495495
/// Cleans the build artefacts from workspace data.
@@ -661,7 +661,7 @@ extension Workspace {
661661
if forceResolvedVersions {
662662
manifests = self._resolveToResolvedVersion(root: root, diagnostics: diagnostics)
663663
} else {
664-
manifests = self._resolve(root: root, diagnostics: diagnostics)
664+
manifests = self._resolve(root: root, forceResolution: false, diagnostics: diagnostics)
665665
}
666666
let externalManifests = manifests.allManifests()
667667

@@ -697,9 +697,10 @@ extension Workspace {
697697
/// checkout will be restored according to its pin.
698698
public func resolve(
699699
root: PackageGraphRootInput,
700+
forceResolution: Bool = false,
700701
diagnostics: DiagnosticsEngine
701702
) {
702-
_resolve(root: root, diagnostics: diagnostics)
703+
_resolve(root: root, forceResolution: forceResolution, diagnostics: diagnostics)
703704
}
704705

705706
/// Loads and returns manifests at the given paths.
@@ -1215,6 +1216,7 @@ extension Workspace {
12151216
@discardableResult
12161217
fileprivate func _resolve(
12171218
root: PackageGraphRootInput,
1219+
forceResolution: Bool,
12181220
extraConstraints: [RepositoryPackageConstraint] = [],
12191221
diagnostics: DiagnosticsEngine,
12201222
retryOnPackagePathMismatch: Bool = true
@@ -1265,7 +1267,7 @@ extension Workspace {
12651267

12661268
// If we don't need resolution and there are no extra constraints,
12671269
// just validate pinsStore and return.
1268-
if !result.resolve && extraConstraints.isEmpty {
1270+
if !result.resolve && extraConstraints.isEmpty && !forceResolution {
12691271
return currentManifests
12701272
}
12711273

@@ -1345,6 +1347,7 @@ extension Workspace {
13451347
// we have the manifest files of all the dependencies.
13461348
return self._resolve(
13471349
root: root,
1350+
forceResolution: forceResolution,
13481351
extraConstraints: extraConstraints,
13491352
diagnostics: diagnostics,
13501353
retryOnPackagePathMismatch: false

0 commit comments

Comments
 (0)