Skip to content

Commit 609d57e

Browse files
authored
Duplicate error message on package resolved (#3258)
motivation: fix a bug where in some cases a duplicate error message is printed changes: only try to load the graph if the previous operation succeeded
1 parent 70f81bb commit 609d57e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Sources/Commands/SwiftPackageTool.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,19 @@ extension SwiftPackageTool {
133133
dryRun: dryRun
134134
)
135135

136-
if let pinsStore = swiftTool.diagnostics.wrap({ try workspace.pinsStore.load() }), let changes = changes, dryRun {
137-
logPackageChanges(changes: changes, pins: pinsStore)
138-
}
139-
140-
if !dryRun {
141-
// try to load the graph which will emit any errors
136+
// try to load the graph which will emit any errors
137+
if !swiftTool.diagnostics.hasErrors {
142138
_ = try workspace.loadPackageGraph(
143139
rootInput: swiftTool.getWorkspaceRoot(),
144140
diagnostics: swiftTool.diagnostics
145141
)
142+
}
146143

144+
if let pinsStore = swiftTool.diagnostics.wrap({ try workspace.pinsStore.load() }), let changes = changes, dryRun {
145+
logPackageChanges(changes: changes, pins: pinsStore)
146+
}
147+
148+
if !dryRun {
147149
// Throw if there were errors when loading the graph.
148150
// The actual errors will be printed before exiting.
149151
guard !swiftTool.diagnostics.hasErrors else {

0 commit comments

Comments
 (0)