Skip to content

Commit 70262ab

Browse files
committed
Print reason for requiring resolution in verbose mode
This is a pretty basic translation from `WorkspaceResolveReason` into prose which may need some improvements in the future, but it's a start at least.
1 parent 0b0b22b commit 70262ab

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

Sources/Workspace/Workspace.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,11 +2033,28 @@ extension Workspace {
20332033
pinsStore: pinsStore
20342034
)
20352035

2036-
if precomputationResult.isRequired {
2036+
if case let .required(result) = precomputationResult {
2037+
let reason: String
2038+
if verbosity != .concise {
2039+
switch result {
2040+
case .forced:
2041+
reason = "\nResolution is required because it was forced."
2042+
case .newPackages(let packages):
2043+
let packagesString = packages.map { $0.name }.joined(separator: ", ")
2044+
reason = "\nResolution is required because there are new packages in the graph: \(packagesString)"
2045+
case .packageRequirementChange(let package, let state, let requirement):
2046+
reason = "\nResolution is required because the requirement of package '\(package.name)' changed: \(state) => \(requirement)"
2047+
case .other:
2048+
reason = "\nResolution is required for an unknown reason"
2049+
}
2050+
} else {
2051+
reason = ""
2052+
}
2053+
20372054
if !fileSystem.exists(self.location.resolvedVersionsFile) {
2038-
diagnostics.emit(error: "a resolved file is required when automatic dependency resolution is disabled and should be placed at \(self.location.resolvedVersionsFile.pathString)")
2055+
diagnostics.emit(error: "a resolved file is required when automatic dependency resolution is disabled and should be placed at \(self.location.resolvedVersionsFile.pathString)\(reason)")
20392056
} else {
2040-
diagnostics.emit(error: "an out-of-date resolved file was detected at \(self.location.resolvedVersionsFile.pathString), which is not allowed when automatic dependency resolution is disabled; please make sure to update the file to reflect the changes in dependencies")
2057+
diagnostics.emit(error: "an out-of-date resolved file was detected at \(self.location.resolvedVersionsFile.pathString), which is not allowed when automatic dependency resolution is disabled; please make sure to update the file to reflect the changes in dependencies\(reason)")
20412058
}
20422059
}
20432060

0 commit comments

Comments
 (0)