Skip to content

Commit

Permalink
fix(swiftpm): Remove an invalid fallback for the VCS revision
Browse files Browse the repository at this point in the history
Leave the `vcs.revision` blank if the revision is not available for
consistency with other package managers.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Feb 7, 2024
1 parent ceb7e84 commit 250df58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 1 addition & 5 deletions plugins/package-managers/swiftpm/src/main/kotlin/SwiftPm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ private fun SwiftPackage.toId(pinsByIdentity: Map<String, PinV2>): Identifier =
)

private fun SwiftPackage.toVcsInfo(pinsByIdentity: Map<String, PinV2>): 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<String, PinV2>): Package =
createPackage(toId(pinsByIdentity), toVcsInfo(pinsByIdentity))
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 250df58

Please sign in to comment.