Skip to content

Commit

Permalink
fix(CocoaPods): Added Sub Dependency to DependencyMap
Browse files Browse the repository at this point in the history
Signed-off-by: ksg97031 <[email protected]>
  • Loading branch information
ksg97031 committed Sep 21, 2023
1 parent e40c142 commit 4daab7a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class CocoaPods(

val podspecCommand = runCatching {
run(
"spec", "which", podspecName,
"spec", "which", "^$podspecName$",
"--version=${id.version}",
"--allow-root",
"--regex",
Expand Down Expand Up @@ -249,6 +249,26 @@ private fun getPackageReferences(podfileLock: File): Set<PackageReference> {

val dependencies = node[entry]?.map { it.textValue().substringBefore(" ") }.orEmpty()
dependenciesForName.getOrPut(name) { mutableSetOf() } += dependencies

// If this node has sub dependencies, append them to the dependency tracking.
// Sub dependencies are additional dependencies that are required.
// For more details, refer to issue #7523.
if (node is ObjectNode) {
val subEntries = node[entry].map { it.textValue() }
subEntries.filter { it.contains("(= ") }.forEach { subEntry ->
val (subDependencyName, subDependencyVersion) = NAME_AND_VERSION_REGEX.find(subEntry)!!.groups.let {
it[1]!!.value to it[2]!!.value.removeSurrounding("(= ", ")")
}

// Add sub dependency if it's not already tracked
if (!versionForName.containsKey(subDependencyName)) {
versionForName[subDependencyName] = subDependencyVersion

val subDependencies = node[subEntry]?.map { it.textValue().substringBefore(" ") }.orEmpty()
dependenciesForName.getOrPut(subDependencyName) { mutableSetOf() } += subDependencies
}
}
}
}

fun createPackageReference(name: String): PackageReference =
Expand Down

0 comments on commit 4daab7a

Please sign in to comment.