From 250df58c2464c37d6b27e5bb411c0ff7df27ded9 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Wed, 7 Feb 2024 16:55:10 +0100 Subject: [PATCH] fix(swiftpm): Remove an invalid fallback for the VCS revision Leave the `vcs.revision` blank if the revision is not available for consistency with other package managers. Signed-off-by: Frank Viernau --- .../projects/synthetic/expected-output-only-lockfile-v1.yml | 4 ++-- plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/plugins/package-managers/swiftpm/src/funTest/assets/projects/synthetic/expected-output-only-lockfile-v1.yml b/plugins/package-managers/swiftpm/src/funTest/assets/projects/synthetic/expected-output-only-lockfile-v1.yml index 74a7b2f4fd1b8..320581788ab07 100644 --- a/plugins/package-managers/swiftpm/src/funTest/assets/projects/synthetic/expected-output-only-lockfile-v1.yml +++ b/plugins/package-managers/swiftpm/src/funTest/assets/projects/synthetic/expected-output-only-lockfile-v1.yml @@ -95,12 +95,12 @@ packages: vcs: type: "Git" url: "https://github.com/apple/swift-llbuild.git" - revision: "9.0.8" + revision: "" path: "" vcs_processed: type: "Git" url: "https://github.com/apple/swift-llbuild.git" - revision: "9.0.8" + revision: "" path: "" - id: "Swift::github.com/braze-inc/braze-ios-sdk:branch-master" purl: "pkg:swift/github.com%2Fbraze-inc%2Fbraze-ios-sdk@branch-master" diff --git a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt index d8e237e536b60..b3ca9b1e5771f 100644 --- a/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt +++ b/plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt @@ -194,10 +194,7 @@ private fun SwiftPackage.toId(pinsByIdentity: Map): Identifier = ) private fun SwiftPackage.toVcsInfo(pinsByIdentity: Map): VcsInfo = - pinsByIdentity[identity]?.toVcsInfo() ?: run { - val vcsInfoFromUrl = VcsHost.parseUrl(url) - return vcsInfoFromUrl.takeUnless { it.revision.isBlank() } ?: vcsInfoFromUrl.copy(revision = version) - } + pinsByIdentity[identity]?.toVcsInfo() ?: VcsHost.parseUrl(url) private fun SwiftPackage.toPackage(pinsByIdentity: Map): Package = createPackage(toId(pinsByIdentity), toVcsInfo(pinsByIdentity)) @@ -241,7 +238,6 @@ private fun PinV2.toVcsInfo(): VcsInfo { return if (vcsInfoFromUrl.revision.isBlank() && state != null) { when { !state.revision.isNullOrBlank() -> vcsInfoFromUrl.copy(revision = state.revision) - !state.version.isNullOrBlank() -> vcsInfoFromUrl.copy(revision = state.version) else -> vcsInfoFromUrl } } else {