@@ -138,14 +138,26 @@ private extension SwiftPackageFileAnalyzer {
138
138
}
139
139
140
140
func analyzeTargetResources(
141
- oldResources: [ SwiftPackageDescription . Target . Resource ] ,
142
- newResources: [ SwiftPackageDescription . Target . Resource ] ,
141
+ oldResources old : [ SwiftPackageDescription . Target . Resource ] ,
142
+ newResources new : [ SwiftPackageDescription . Target . Resource ] ,
143
143
oldProjectBasePath: String ,
144
144
newProjectBasePath: String
145
145
) throws -> [ String ] {
146
146
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) )
149
161
150
162
let addedResourcePaths = newResourcePaths. subtracting ( oldResourcePaths)
151
163
let consistentResourcePaths = oldResourcePaths. intersection ( newResourcePaths)
@@ -160,16 +172,16 @@ private extension SwiftPackageFileAnalyzer {
160
172
161
173
listOfChanges += consistentResourcePaths. compactMap { path in
162
174
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 } ) ,
165
177
newResource. description != oldResource. description
166
178
else { return nil }
167
179
168
180
return " Changed resource from ` \( oldResource. description) ` to ` \( newResource. description) ` "
169
181
}
170
182
171
183
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 }
173
185
return " Removed resource \( resource. description) "
174
186
}
175
187
0 commit comments