@@ -531,44 +531,65 @@ extension ImpactAnalysisWorkspaceMapper {
531531
532532 // MARK: - Lockfiles diff calculation
533533
534- private func lockfiles( ) throws -> ( original: CocoapodsLockfile , new: CocoapodsLockfile ) {
535- let originalLockfile : Data
534+ private func lockfiles( ) throws -> ( original: CocoapodsLockfile ? , new: CocoapodsLockfile ? ) {
535+ let originalLockfile : Data ?
536536 let originalLockfileContext : ParseYamlContext
537- let newLockfile : Data
537+ let newLockfile : Data ?
538538 let newLockfileContext : ParseYamlContext
539539
540540 let lockfilePath = try RelativePath ( validating: " Geko/Dependencies/Cocoapods.lock " )
541541 if environment. impactAnalysisDebug {
542542 let rootDir = fileHandler. currentPath
543543
544- originalLockfile = try system. capture ( [ " git " , " show " , " HEAD: \( lockfilePath. pathString) " ] ) . chomp ( ) . data ( using: . utf8) !
544+ originalLockfile = try ? system. capture ( [ " git " , " show " , " HEAD: \( lockfilePath. pathString) " ] ) . chomp ( )
545+ . data ( using: . utf8)
545546 originalLockfileContext = . git( path: lockfilePath, ref: " HEAD " )
546547
547548 let newLockfilePath = rootDir. appending ( lockfilePath)
548- newLockfile = try fileHandler. readFile ( newLockfilePath)
549+ newLockfile = try ? fileHandler. readFile ( newLockfilePath)
549550 newLockfileContext = . file( path: newLockfilePath)
550551 } else {
551- originalLockfile = try system. capture ( [ " git " , " show " , " \( targetRef) : \( lockfilePath. pathString) " ] ) . chomp ( )
552- . data ( using: . utf8) !
552+ originalLockfile = try ? system. capture ( [ " git " , " show " , " \( targetRef) : \( lockfilePath. pathString) " ] ) . chomp ( )
553+ . data ( using: . utf8)
553554 originalLockfileContext = . git( path: lockfilePath, ref: " HEAD " )
554555
555- newLockfile = try system. capture ( [ " git " , " show " , " \( sourceRef) : \( lockfilePath. pathString) " ] ) . chomp ( )
556- . data ( using: . utf8) !
556+ newLockfile = try ? system. capture ( [ " git " , " show " , " \( sourceRef) : \( lockfilePath. pathString) " ] ) . chomp ( )
557+ . data ( using: . utf8)
557558 newLockfileContext = . git( path: lockfilePath, ref: " HEAD " )
558559 }
559560
560- let originalLockfileYml = try CocoapodsLockfile . from ( data: originalLockfile, context: originalLockfileContext) !
561- let newLockfileYml = try CocoapodsLockfile . from ( data: newLockfile, context: newLockfileContext) !
561+ var originalLockfileYml : CocoapodsLockfile ?
562+ var newLockfileYml : CocoapodsLockfile ?
563+
564+ if let originalLockfile {
565+ originalLockfileYml = try CocoapodsLockfile . from ( data: originalLockfile, context: originalLockfileContext)
566+ }
567+
568+ if let newLockfile {
569+ newLockfileYml = try CocoapodsLockfile . from ( data: newLockfile, context: newLockfileContext)
570+ }
562571
563572 return ( originalLockfileYml, newLockfileYml)
564573 }
565574
566575 private func lockfileChanges(
567576 workspace: inout WorkspaceWithProjects ,
568577 externalDependenciesGraph: DependenciesGraph ,
569- originalLockfile: CocoapodsLockfile ,
570- newLockfile: CocoapodsLockfile
578+ originalLockfile: CocoapodsLockfile ? ,
579+ newLockfile: CocoapodsLockfile ?
571580 ) throws -> Set < ImpactGraphDependency > {
581+ guard let newLockfile else { return [ ] }
582+
583+ guard let originalLockfile else {
584+ var changedDependencies = Set < String > ( )
585+
586+ for (_, newSourceData) in newLockfile. podsBySource {
587+ changedDependencies. formUnion ( newSourceData. pods. keys)
588+ }
589+
590+ return mapImpactDependencies ( from: changedDependencies, externalDependenciesGraph: externalDependenciesGraph)
591+ }
592+
572593 var changedDependencies = Set < String > ( )
573594
574595 func compare( _ origLockfile: CocoapodsLockfile , _ newLockfile: CocoapodsLockfile ) {
@@ -597,6 +618,13 @@ extension ImpactAnalysisWorkspaceMapper {
597618 compare ( originalLockfile, newLockfile)
598619 compare ( newLockfile, originalLockfile)
599620
621+ return mapImpactDependencies ( from: changedDependencies, externalDependenciesGraph: externalDependenciesGraph)
622+ }
623+
624+ private func mapImpactDependencies(
625+ from changedDependencies: Set < String > ,
626+ externalDependenciesGraph: DependenciesGraph
627+ ) -> Set < ImpactGraphDependency > {
600628 var result = Set < ImpactGraphDependency > ( )
601629
602630 for dependency in changedDependencies {
0 commit comments