@@ -138,14 +138,26 @@ private extension SwiftPackageFileAnalyzer {
138138 }
139139
140140 func analyzeTargetResources(
141- oldResources: [ SwiftPackageDescription . Target . Resource ] ,
142- newResources: [ SwiftPackageDescription . Target . Resource ] ,
141+ oldResources old : [ SwiftPackageDescription . Target . Resource ] ,
142+ newResources new : [ SwiftPackageDescription . Target . Resource ] ,
143143 oldProjectBasePath: String ,
144144 newProjectBasePath: String
145145 ) throws -> [ String ] {
146146
147- let oldResourcePaths = Set ( oldResources. map ( \. path) . map { $0. trimmingPrefix ( oldProjectBasePath) } )
148- let newResourcePaths = Set ( newResources. map ( \. path) . map { $0. trimmingPrefix ( newProjectBasePath) } )
147+ let oldResources = old. map { resource in
148+ var updated = resource
149+ updated. path = " . \( updated. path. trimmingPrefix ( oldProjectBasePath) ) "
150+ return updated
151+ }
152+
153+ let newResources = new. map { resource in
154+ var updated = resource
155+ updated. path = " . \( updated. path. trimmingPrefix ( newProjectBasePath) ) "
156+ return updated
157+ }
158+
159+ let oldResourcePaths = Set ( oldResources. map ( \. path) )
160+ let newResourcePaths = Set ( newResources. map ( \. path) )
149161
150162 let addedResourcePaths = newResourcePaths. subtracting ( oldResourcePaths)
151163 let consistentResourcePaths = oldResourcePaths. intersection ( newResourcePaths)
@@ -160,16 +172,16 @@ private extension SwiftPackageFileAnalyzer {
160172
161173 listOfChanges += consistentResourcePaths. compactMap { path in
162174 guard
163- let newResource = newResources. first ( where: { $0. path. trimmingPrefix ( newProjectBasePath ) == path } ) ,
164- let oldResource = oldResources. first ( where: { $0. path. trimmingPrefix ( oldProjectBasePath ) == path } ) ,
175+ let newResource = newResources. first ( where: { $0. path == path } ) ,
176+ let oldResource = oldResources. first ( where: { $0. path == path } ) ,
165177 newResource. description != oldResource. description
166178 else { return nil }
167179
168180 return " Changed resource from ` \( oldResource. description) ` to ` \( newResource. description) ` "
169181 }
170182
171183 listOfChanges += removedResourcePaths. compactMap { path in
172- guard let resource = oldResources. first ( where: { $0. path. trimmingPrefix ( oldProjectBasePath ) == path } ) else { return nil }
184+ guard let resource = oldResources. first ( where: { $0. path == path } ) else { return nil }
173185 return " Removed resource \( resource. description) "
174186 }
175187
0 commit comments