Skip to content

Commit

Permalink
fix: Sort folder sections in the report (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Feb 24, 2025
1 parent 369940b commit 00e650e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/ReporterCore/Model/Report.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public struct Report {
}
}

public var folders: [KeyedChanges]
public let folders: [KeyedChanges]

public init(folders: [KeyedChanges]) {
self.folders = folders
self.folders = folders.sorted { $0.name.localizedStandardCompare($1.name) == .orderedAscending }
}

}
5 changes: 3 additions & 2 deletions Sources/ReporterCore/Reporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ public class Reporter {
try encoder.encode(newState).write(to: snapshotURL)

// Compare the snapshots for each folder.
var report: Report = Report(folders: [])
var folders: [KeyedChanges] = []
for (url, snapshot) in newState.snapshots {
console.log("Checking '\(url.path)'...")
let oldSnapshot = oldState.snapshots[url] ?? State.Snapshot()
let changes = snapshot.changes(from: oldSnapshot)
report.folders.append(KeyedChanges(url: url, changes: changes))
folders.append(KeyedChanges(url: url, changes: changes))
}
let report: Report = Report(folders: folders)

return report
}
Expand Down

0 comments on commit 00e650e

Please sign in to comment.