Skip to content

Commit 740a6c5

Browse files
authored
Improve displayVersion and scmRevision description exposed by PluginContextSerializer (#7934)
Avoid using `String(describing:)` to create strings that can be utilized by consumers. ### Motivation: Version and revision strings with `Optional(...)` in them look less-than-great ### Modifications: Utilized `thing?.description ?? "nil"` rather than `String(describing: thing)`. ### Result: Improved the readability of `displayVersion` and `scmRevision` in a `Package`'s `origin: PackagePlugin.PackageOrigin`.
1 parent f55fbef commit 740a6c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/SPMBuildCore/Plugins/PluginContextSerializer.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ internal struct PluginContextSerializer {
236236
case .fileSystem(let path):
237237
return .local(path: try serialize(path: path))
238238
case .localSourceControl(let path):
239-
return .repository(url: path.asURL.absoluteString, displayVersion: String(describing: package.manifest.version), scmRevision: String(describing: package.manifest.revision))
239+
return .repository(url: path.asURL.absoluteString, displayVersion: package.manifest.version?.description ?? "no version", scmRevision: package.manifest.revision ?? "no revision")
240240
case .remoteSourceControl(let url):
241-
return .repository(url: url.absoluteString, displayVersion: String(describing: package.manifest.version), scmRevision: String(describing: package.manifest.revision))
241+
return .repository(url: url.absoluteString, displayVersion: package.manifest.version?.description ?? "no version", scmRevision: package.manifest.revision ?? "no revision")
242242
case .registry(let identity):
243-
return .registry(identity: identity.description, displayVersion: String(describing: package.manifest.version))
243+
return .registry(identity: identity.description, displayVersion: package.manifest.version?.description ?? "no version")
244244
}
245245
}
246246

0 commit comments

Comments
 (0)