Skip to content

Commit

Permalink
fix(cocoapods): Added Sub Dependency Tracking for CocoaPods
Browse files Browse the repository at this point in the history
This change ensures that these sub dependencies are
properly tracked and added to the dependency list when encountered

Signed-off-by: ksg97031 <[email protected]>
  • Loading branch information
ksg97031 committed Sep 20, 2023
1 parent e40c142 commit c3f2108
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions plugins/package-managers/cocoapods/src/main/kotlin/CocoaPods.kt
Original file line number Diff line number Diff line change
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 c3f2108

Please sign in to comment.