Skip to content

Commit 87254d2

Browse files
authored
Do not emit errors about the resolved file being out-of-date if cloning already fails (#5916)
The additional bogus error muddles the water on what the underlying error was, so we should simply not emit it. rdar://84000597
1 parent 7e015d6 commit 87254d2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Sources/Workspace/Workspace.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public enum WorkspaceResolveReason: Equatable {
4545

4646
/// An unknown reason.
4747
case other(String)
48+
49+
/// Errors previously reported, e.g. during cloning. This will skip emitting additional unhelpful diagnostics.
50+
case errorsPreviouslyReported
4851
}
4952

5053
public struct PackageFetchDetails {
@@ -2302,7 +2305,7 @@ extension Workspace {
23022305
observabilityScope: observabilityScope
23032306
)
23042307

2305-
if case let .required(reason) = precomputationResult {
2308+
if case let .required(reason) = precomputationResult, reason != .errorsPreviouslyReported {
23062309
let reasonString = Self.format(workspaceResolveReason: reason)
23072310

23082311
if !fileSystem.exists(self.location.resolvedVersionsFile) {
@@ -2607,6 +2610,10 @@ extension Workspace {
26072610
let resolver = PubgrubDependencyResolver(provider: precomputationProvider, pinsMap: pinsStore.pinsMap, observabilityScope: observabilityScope)
26082611
let result = resolver.solve(constraints: computedConstraints)
26092612

2613+
guard !observabilityScope.errorsReported else {
2614+
return .required(reason: .errorsPreviouslyReported)
2615+
}
2616+
26102617
switch result {
26112618
case .success:
26122619
return .notRequired
@@ -3368,6 +3375,10 @@ fileprivate extension PackageDependency {
33683375

33693376
extension Workspace {
33703377
public static func format(workspaceResolveReason reason: WorkspaceResolveReason) -> String {
3378+
guard reason != .errorsPreviouslyReported else {
3379+
return ""
3380+
}
3381+
33713382
var result = "Running resolver because "
33723383

33733384
switch reason {
@@ -3415,7 +3426,7 @@ extension Workspace {
34153426

34163427
result.append(" requirement.")
34173428
default:
3418-
result.append(" requirements have changed.")
3429+
result.append("requirements have changed.")
34193430
}
34203431

34213432
return result

Tests/WorkspaceTests/WorkspaceTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4107,7 +4107,7 @@ final class WorkspaceTests: XCTestCase {
41074107
// Check force resolve. This should produce an error because the resolved file is out-of-date.
41084108
workspace.checkPackageGraphFailure(roots: ["Root"], forceResolvedVersions: true) { diagnostics in
41094109
testDiagnostics(diagnostics) { result in
4110-
result.check(diagnostic: "an out-of-date resolved file was detected at \(sandbox.appending(components: "Package.resolved")), which is not allowed when automatic dependency resolution is disabled; please make sure to update the file to reflect the changes in dependencies. Running resolver because requirements have changed.", severity: .error)
4110+
result.check(diagnostic: "an out-of-date resolved file was detected at \(sandbox.appending(components: "Package.resolved")), which is not allowed when automatic dependency resolution is disabled; please make sure to update the file to reflect the changes in dependencies. Running resolver because requirements have changed.", severity: .error)
41114111
}
41124112
}
41134113
workspace.checkManagedDependencies { result in

0 commit comments

Comments
 (0)