Skip to content

Commit

Permalink
fix: Use folder names for headers (instead of paths) (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Feb 13, 2025
1 parent 597e3d9 commit bc17f77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Sources/Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct Command: AsyncParsableCommand {
print("Checking \(url)...")
let oldSnapshot = oldState.snapshots[url] ?? State.Snapshot()
let changes = snapshot.changes(from: oldSnapshot)
report.folders.append(KeyedChanges(name: url.path, url: url, changes: changes))
report.folders.append(KeyedChanges(url: url, changes: changes))
}

// Return early if there are no outstanding changes.
Expand All @@ -170,7 +170,7 @@ struct Command: AsyncParsableCommand {
let context: [String: Any] = ["report": report]
let summary = try environment.renderTemplate(string: """
{% for item in report.folders %}
{{ item.name }}
{{ item.name }} ({{ item.path }})
{{ item.changes.additions.count }} additions
{% for addition in item.changes.additions %}{{ addition }}{% endfor %}
Expand All @@ -187,6 +187,7 @@ struct Command: AsyncParsableCommand {
<html>
{% for item in report.folders %}
<h2>{{ item.name }}</h2>
<p>{{ item.path }}</p>
{% if item.changes.isEmpty %}
<p>No changes.</p>
{% else %}
Expand Down
11 changes: 10 additions & 1 deletion Sources/Model/KeyedChanges.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ import Foundation

struct KeyedChanges {

let name: String
let url: URL
let changes: Changes
let name: String
let path: String

init(url: URL, changes: Changes) {
self.url = url
self.changes = changes
self.name = url.lastPathComponent
self.path = url.path
}

}

0 comments on commit bc17f77

Please sign in to comment.