Skip to content

Commit 61a369b

Browse files
authored
Duplicate error message on package resolved (#3257)
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 49bed82 commit 61a369b

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
@@ -134,17 +134,19 @@ extension SwiftPackageTool {
134134
dryRun: dryRun
135135
)
136136

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

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

0 commit comments

Comments
 (0)