Skip to content

Commit a928526

Browse files
committed
adapting the path everywhere
1 parent 66b7a55 commit a928526

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

Sources/PublicModules/PADPackageFileAnalyzer/SwiftPackageFileAnalyzer+Targets.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Sources/Shared/Package/SwiftPackageFileHelperModule/SwiftPackageDescription.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ extension SwiftPackageDescription.Target: CustomStringConvertible {
263263
package extension SwiftPackageDescription.Target {
264264

265265
struct Resource: Codable, Equatable {
266-
package let path: String
266+
package var path: String
267267
package let rule: Rule
268268
}
269269
}

0 commit comments

Comments
 (0)