Skip to content

Commit

Permalink
refactor(spm): Factor out createPackage()
Browse files Browse the repository at this point in the history
Prepare for re-use in an upcoming change.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Jan 19, 2024
1 parent 2d909ee commit bd860f3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions plugins/package-managers/spm/src/main/kotlin/SpmModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,7 @@ abstract class SpmDependency {
abstract val vcs: VcsInfo
abstract val id: Identifier

fun toPackage(): Package {
return Package(
vcs = vcs,
description = "",
id = id,
binaryArtifact = RemoteArtifact.EMPTY,
sourceArtifact = RemoteArtifact.EMPTY,
declaredLicenses = emptySet(), // SPM files do not declare any licenses.
homepageUrl = ""
)
}
fun toPackage(): Package = createPackage(id, vcs)
}

/**
Expand Down Expand Up @@ -140,6 +130,17 @@ data class AppDependency(
}
}

private fun createPackage(id: Identifier, vcsInfo: VcsInfo) =
Package(
vcs = vcsInfo,
description = "",
id = id,
binaryArtifact = RemoteArtifact.EMPTY,
sourceArtifact = RemoteArtifact.EMPTY,
declaredLicenses = emptySet(), // SPM files do not declare any licenses.
homepageUrl = ""
)

/**
* Return the canonical name for a package based on the given [repositoryUrl].
* The algorithm assumes that the repository URL does not point to the local file
Expand Down

0 comments on commit bd860f3

Please sign in to comment.