Skip to content

Commit

Permalink
refactor(cocoapods): Decompose a MapEntry
Browse files Browse the repository at this point in the history
Make the variable names more speaking and reduce the diff of an upcoming
change.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Jul 16, 2024
1 parent d686957 commit 2df46c6
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,19 @@ private fun parseLockfile(podfileLock: File): LockfileData {
}
}

val externalSources = root.get("CHECKOUT OPTIONS")?.fields()?.asSequence()?.mapNotNull {
val checkout = it.value as ObjectNode
val externalSources = root.get("CHECKOUT OPTIONS")?.fields()?.asSequence()?.mapNotNull { (name, checkout) ->
val url = checkout[":git"]?.textValue() ?: return@mapNotNull null
val revision = checkout[":commit"].textValueOrEmpty()

// The version written to the lockfile matches the version specified in the project's ".podspec" file at the
// given revision, so the same version might be used in different revisions. To still get a unique identifier,
// append the revision to the version.
val versionFromPodspec = checkNotNull(resolvedVersions[it.key])
val versionFromPodspec = checkNotNull(resolvedVersions[name])
val uniqueVersion = "$versionFromPodspec-$revision"
val id = Identifier("Pod", "", it.key, uniqueVersion)
val id = Identifier("Pod", "", name, uniqueVersion)

// Write the unique version back for correctly associating dependencies below.
resolvedVersions[it.key] = uniqueVersion
resolvedVersions[name] = uniqueVersion

id to Package(
id = id,
Expand Down

0 comments on commit 2df46c6

Please sign in to comment.